How to make pip install to PATH on Linux?
Rather than messing with existing directories in PATH
, consider adding the one pip
installs to.
The best place to do so is ~/.profile
file. You do it by adding to it the following line:
export PATH="$HOME/.local/bin:$PATH"
Install a Python package into a different directory using pip?
Use:
pip install --install-option="--prefix=$PREFIX_PATH" package_name
You might also want to use --ignore-installed
to force all dependencies to be reinstalled using this new prefix. You can use --install-option
to multiple times to add any of the options you can use with python setup.py install
(--prefix
is probably what you want, but there are a bunch more options you could use).
How to change pip installation path
You can tell pip where to install the package. Use the -t
flag , that means the target directory where you want to install the package. Have have look at pip install --help
-t, --target <dir> Install packages into <dir>. By default this will not replace existing
files/folders in <dir>. Use --upgrade to replace existing packages in <dir> with
new versions.
You can change this on permanent basis by changing the pip.ini configuration file. See this for detail: pip install path
On Unix and Mac OS X the configuration file is:
$HOME/.pip/pip.conf
On Windows, the configuration file is: %HOME%\pip\pip.ini
The %HOME% is located in
C:\Users\Bob on windows assuming your name is Bob
You may have to create the pip.ini file when you find your pip directory. Within your pip.ini or pip.config you will then need to put (assuming your on windows) something like
[global]
target=C:\Users\<username>\Desktop
Adding installed PIP package to path automatically
setuptools
, pip
and easy_install
don't modify the system PATH variable. The <python directory>\Scripts
directory, where all of them install the script by default, is normally added to PATH by the Python installer during installation.
If the scripts folder was not added to your PATH during installation, you can fix that by running <python directory>\Tools\scripts\win_add2path.py
. (See How can I find where Python is installed on Windows?)
The above sample setup.py file worked fine for me (with the Scripts directory in PATH), by the way. I tested it with
python setup.py bdist_wheel
pip install dist\foo-0.0.1-py3-none-any.whl
and
python setup.py sdist
pip install dist\foo-0.0.1.zip
pip installs packages successfully, but executables not found from command line
check your $PATH
tox
has a command line mode:
audrey:tests jluc$ pip list | grep tox
tox (2.3.1)
where is it?
(edit: the 2.7
stuff doesn't matter much here, sub in any 3.x
and pip's behaving pretty much the same way)
audrey:tests jluc$ which tox
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/tox
and what's in my $PATH?
audrey:tests jluc$ echo $PATH
/opt/chefdk/bin:/opt/chefdk/embedded/bin:/opt/local/bin:..../opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin...
Notice the /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin? That's what allows finding my pip-installed stuff
Now, to see where things are from Python, try doing this (substitute rosdep
for tox
).
$python
>>> import tox
>>> tox.__file__
that prints out:
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tox/__init__.pyc'
Now, cd to the directory right above lib
in the above. Do you see a bin directory? Do you see rosdep
in that bin? If so try adding the bin
to your $PATH.
audrey:2.7 jluc$ cd /opt/local/Library/Frameworks/Python.framework/Versions/2.7
audrey:2.7 jluc$ ls -1
output:
Headers
Python
Resources
bin
include
lib
man
share
install python package at current directory
You can use the target (t
) flag of pip install
to specify a target location for installation.
In use:
pip install -r requirements.txt -t /path/to/directory
to the current directory:
pip install -r requirements.txt -t .
How to change default install location for pip
According to pip documentation at
http://pip.readthedocs.org/en/stable/user_guide/#configuration
You will need to specify the default install location within a pip.ini file, which, also according to the website above is usually located as follows
On Unix and Mac OS X the configuration file is: $HOME/.pip/pip.conf
On Windows, the configuration file is: %HOME%\pip\pip.ini
The %HOME% is located in C:\Users\Bob
on windows assuming your name is Bob
On linux the $HOME
directory can be located by using cd ~
You may have to create the pip.ini
file when you find your pip directory. Within your pip.ini
or pip.config
you will then need to put (assuming your on windows) something like
[global]
target=C:\Users\Bob\Desktop
Except that you would replace C:\Users\Bob\Desktop
with whatever path you desire. If you are on Linux you would replace it with something like /usr/local/your/path
After saving the command would then be
pip install pandas
However, the program you install might assume it will be installed in a certain directory and might not work as a result of being installed elsewhere.
Related Topics
Cannot Bind Numpad Minus Key on Linux with Tkinter
"Valueerror: _Type_ 'V' Not Supported" Error After Installing Pyreadline
Using && in Subprocess.Popen for Command Chaining
How to Programmatically Edit Excel Sheets
/Usr/Bin/Env: Python2: No Such File or Directory
Python Linux Selenium: Chrome Not Reachable
Which Command to Use for Checking Whether Python Is 64Bit or 32Bit
Installing Python 2.7 Without Root
Error with Igraph Library - Deprecated Library
How to Control the Keyboard and Mouse with Python
Why Does Python "Preemptively" Hang When Trying to Calculate a Very Large Number
Can't Install Gcloud on Amazon Linux:Invalid Syntax
How to Disable Stdout Buffer When Running Shell
Oserror 38 [Errno 38] with Multiprocessing
Subprocess.Popen(): Oserror: [Errno 8] Exec Format Error in Python