Skip to content Skip to sidebar Skip to footer

How Do You Specify Bin Directory For Pip Install With --target Option Enabled

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

Solution 1:

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

Solution 2:

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

Solution 3:

An issue regarding this problem has been created on GitHub: https://github.com/pypa/pip/issues/3934

This is because the --install-option="--install-scripts=$PWD/bin" flag, that is necessary, cannot be used with .whl files:

.../lib/python2.7/site-packages/pip/commands/install.py:194: 
UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)

Solution 4:

With Python 3.9, --target automatically installs executables into subfolder bin of the given target directory.

Post a Comment for "How Do You Specify Bin Directory For Pip Install With --target Option Enabled"