To give an example, if I run the command
sudo pip install gunicorn
There's now a file
/usr/local/bin/gunicorn
and a folder
/usr/local/lib/python2.7/site-packages/gunicorn
And I can run "gunicorn" from the shell.
However, if I run the command
sudo pip install gunicorn --target=~/tmp_directory
There's a folder at
~/tmp_directory/gunicorn
However, there is no "bin/gunicorn" anywhere and I cannot run "gunicorn" from the shell. Looking through the pip documentation I can't find anything for this particular case. The exact reason for my doing this is to try and setup a custom buildpack on Heroku.
Generally you will need to specify --implementation, --platform, and --python-version when using this option. Install to the Python user install directory for your platform. Typically ~/.local/, or %APPDATA%Python on Windows.
To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1. 3 .
By default, on Linux, Pip installs packages to /usr/local/lib/python2. 7/dist-packages. Using virtualenv or --user during install will change this default location.
I just found it's actually possible to tell 'pip' where to put scripts, data etc.
You can use --install-option
to pass options to setuptools. So if you want to specify where to put scripts, you can:
pip install gunicorn --install-option="--install-scripts=$PWD/bin" -t python_modules/
Now you have gunicorn
command inside bin/
in current directory and package installed in target dir python_modules
.
bin/gunicorn
You can sudo ln -s ~/tmp_directory/gunicorn /usr/bin/gunicorn
.
If I understand your needs correctly, you're suggested to try virtualenv, a tool to create isolated Python environments. You can install different versions of Python packages for each of your project on the same server. Highly recommended for Python development. I'm using virtualenvwrapper, a wrapper to make it a bit easier to use
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With