I am trying to run a script I wrote and I hope to distribute. Each time I run outside of an activated virtual environment "No module named", I guess it is because it has some dependencies that are not in-built. How do I overcome this issue ?
CodePudding user response:
You need to install that modules outside the virtual environment that is directly in the system.
And If you want to distribute your script then add all of your required modules in requirements.txt file and provide this file to another user along your script and then just run this command to install the modules:-
pip install -r requirements.txt
OR
python3 -m pip install -r requirements.txt
CodePudding user response:
You need to create a requirements file, those who want to use your project can run the command provided by Dinky Arora to get the required packages.
I recommend downloading pipreqs which helps your generate requirement files by running the following command :
pip install pipreqs
Then run :
pipreqs /path/to/project
To generate a requirements file.
Note : You can also use freeze, it does the same job. Moreover, you could generate a setup.py to install your python project all its dependencies.