[Python] Python Equivalent of npm or rubygem
If you don't already have virtualenv installed, then install it globally with:
Now, any interaction with pip is contained within your project.
pip install virtualenv (or pip3 - for python3)
Each Python project should have its own virtualenv installation. It's easy to set one up, just cd to your project's root and:
python3 -m virtualenv env # creates env folder with everything you need
Activate virtualenv:
source env/bin/activate
Deactivate virtualenv: deactivate
Run
pip install package_name==version
for each of your dependencies. They are installed in ./env/lib/python3.x/site-packages/
When you want to save your project's dependencies to a file, run:
pip freeze > requirements.txt
You actually don't need -l or --local if you're in an activated project-specific virtualenv (which you should be).
Now, when you want to install your dependencies from requirements.txt, set up your virtualenv, and run:
pip install -r requirements.txt
That's all.
Comments
Post a Comment