I installed python with brew install python
which pip
/usr/local/bin/pip
my PYTHONPATH
shows /usr/local/lib/python2.7/site-packages/
However, when I try to install something with pip, it goes to the /bin/
directory as shown below. I want things installed to /usr/local/lib/python2.7/site-packages/
. How do I fix this?
pip install virtualenv
Downloading/unpacking virtualenv
Downloading virtualenv-1.11.6-py2.py3-none-any.whl (1.6MB): 1.6MB downloaded
Installing collected packages: virtualenv
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/commands/install.py", line 283, in run
{....}
File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/_vendor/distlib/util.py", line 384, in write_binary_file
with open(path, 'wb') as f:
IOError: [Errno 13] Permission denied: '/bin/virtualenv'
$ pip list
pip (1.5.6)
setuptools (5.4.2)
wsgiref (0.1.2)
$pip show setuptools
---
Name: setuptools
Version: 5.4.2
Location: /usr/local/lib/python2.7/site-packages/setuptools-5.4.2-py2.7.egg
Requires:
So pip already has the basic packages installed to site-packages. However, running the same exact pip to install virtualenv tries to install to /bin/.
There are two ways to install Python packages: Using a requirements.txt file that defines the required packages and their version numbers. But before we start, let’s make sure pip itself is installed! Good news; chances are that Pip is already present on your system. Most Python installers also install Pip.
The short answer is that ~/.local/bin is the default value of Python's User Script Directory and that pip may install executables into this directory if it performs a user-local installation. It may also install files into other subdirectories of ~/.local, which is the default value of the User Base Directory.
Newer versions of pip (8 or later) can directly use the --prefix option: where $PREFIX_PATH is the installation prefix where lib, bin and other top-level folders are placed.
Show activity on this post. The short answer is that ~/.local/bin is the default value of Python's User Script Directory and that pip may install executables into this directory if it performs a user-local installation. It may also install files into other subdirectories of ~/.local, which is the default value of the User Base Directory.
I was running into this same issue when trying to install virtualenv and flask. Turns out I had a .pydistutils.cfg
file in my home directory. I remember placing this there not too long ago as a work around for installing something else. Once I removed this file, running pip install
continued working as expected.
For me, there was a setup.cfg file with the following code
[install]
prefix=
Removing the file fixed it for me.
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