I recently had to switch my machine at work. On the new machine, pip is not anymore.
$ pip --version
...
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/virtualenv-15.0.1.dist-info'
I imagine that this issue is caused by virtualenv, as I never encountered any problems on my old machine and the only difference I find, is that there was no virtualenv package installed on the old machine.
However
$ python -c "import pip; print pip.__version__"
10.0.1
still works.
I would be grateful if anyone could provide help, how to fix this problem or trace down the real problem.
Please note: I do not have root rights.
Here the problem is you don't have permission to the system folder. So whenever you use pip try to use it like this.
python -m pip install --user package
Here the package means the package you need to install using pip. Furthermore try using the following command to upgrade the version of your pip.
python -m pip install --user --upgrade pip
Related
I'm trying to run some code with python. It is using tweepy library. Then, I got this error:
Traceback (most recent call last):
File "script.py", line 1, in <module>
import tweepy
ImportError: No module named 'tweepy'
So, I tried to install dependency:
pip install tweepy
And it get permission denied:
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/sockshandler.py'
Consider using the `--user` option or check the permissions.
Next thing to do is to run using sudo. I had a bad experience by using sudo for docker, because it creates protected files all over my local. But I finally tried it anyway sudo pip install tweepy
It returns success, but I still get the same error when I tried to run python3 myscript.py
But, I see some warning to upgrade the pip, so I think maybe that's it. I tried to upgrade pip using both pip install --upgrade pip and sudo pip install --upgrade pip
Still not working.. I tried one last trick up my sleeve. Change the terminal. I think, "maybe after installing, some environment variable not running on this terminal"
Nope. Not working. I admit it should be a newbie question. Having tried some solution on the web, but still not working. Thanks.
If you use python3, you should be using pip3, pip is most likely the python2 pip.
However, better is using python3 -m pip install tweepy that ensures you use the pip for your specific python version.
You can also install it as a user without sudo for just your local account:
python3 -m pip install --user tweepy
Look at the error message:
... Permission denied: '/usr/local/lib/python2.7 ....
You installed tweepy in your python2 Installation.
Use pip3 install tweepy instead. Maybe with sudo when you get the error with permission denied again. After that you can go with
python3 myscript.py
Use the --user flag, like so...
pip|pip3 install <PACKAGE> --user
This will install it in a location available and writeable to your user
See https://packaging.python.org/tutorials/installing-packages/#installing-to-the-user-site
You seems to have 2 python installations on the machine. Python 3.x and Python 2.7.
When you run the pip command , the alias points to pip2 which installs packages for Python 2.7 - which is clear in your error message
Permission denied: '/usr/local/lib/python2.7/dist-packages/sockshandler.py'
So if you want to install packages for python 3, then use the command pip3 instead of pip.
Like sudo pip3 install tweepy
If you want the pip to work as pip3 you can consider adding an alias with alias pip=pip3
You have to make sure the pip is pointing to right python version.
I am attempting to use Anaconda and running into issues with packages installing in the wrong folders (because I have multiple versions of python installed, which cannot be removed). How do I correctly get new packages installing to the anaconda3 python version?
For example:
pip3 install praw <-- installs to python2.7 folder
$ python -m site --user-site
/home/king/.local/lib/python3.6/site-packages
$ python3 -m site --user-site
/home/king/.local/lib/python3.6/site-packages
$ conda install praw <----fails because cant find package
Tried the solution from here:
$ python3.6 -m pip install praw
PermissionError: [Errno 13] Permission denied: '/home/king/anaconda3/lib/python3.6/site-packages/update_checker.py'
$ sudo -H python3.6 -m pip install praw
sudo: python3.6: command not found
All my python directories
/home/king/anaconda3/lib/python3.6/site-packages
/usr/local/lib/python3.5/dist-packages/
/usr/local/lib/python2.7/dist-packages/
anaconda does not provide pip3, if anaconda is first in your path, use pip. Check with
which pip
To be sure, you are using the pip that corresponds to your python, use:
python -m pip install ...
Edit: Looks like you messed up file permissions of your anaconda install. Maybe by using sudo to install something.
To fix, you could do:
sudo chown -R king:king /home/king/anaconda3
and don't use sudo again to do stuff with the anaconda install in your home.
first of all, it's highly recommanded to install Anaconda to /opt in order to be used by all users (avoid permission problem)
Try to see witch python you use (Anaconda or Native Python) to see with pip you use:
which python
if you find that python you use is on /usr/local/lib that mean you use the native one, so tou have to export the Anaconda/bin to you environment variable to use Anaconda python. and then you can use pip to install your package:
pip install praw
I'm wanting to use django on bluehost, and I've gotten as far as installing python 2.7, then running python get-pip.pyto install / update pip. And now hoping to install virtualenv; the instructions say to run sudo pip install virtualenv but neither the sudo or non-sudo version of this command works.
Sudo is flat out not permitted on Bluehost's shared hosting environment, and when I type pip, I get command not found. So I am to assume pip is still not installed, despite the successful execution of
python get-pip.py
When I type which pip I get nothing, while which easy_install
gives me a path.
So is it there? I'm quite confused.
I've been stuck for some time. Help is much appreciated.
The following command works for me when I want to run pip:
python -m pip install <package_name>
I am trying to install pip without sudo.
Reading the Install Docs, it appears to be possible to use --user to have it being installed in my home directory.
After uninstalling pip from the global scope I tried python get-pip.py --user and obtain the following error:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/wheel-0.29.0.dist-info'
Checking the Install Docs I found the following notice:
Be cautious if you're using a Python install that's managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.
Can I install pip into my home with the casual Ubuntu apt-get python? Or do I also need to build python locally?
As phd mentoined in the comment of my question, cloning pip and installing it via python setup.py install --user worked out fine.
I'm trying to install Python packages, specifically numpy and networkx, using PyCharm on a laptop running Gallium, and I keep getting:
IOError: [Errno 20] Not a directory: '/tmp/pip-build-xMS1YA/numpy/doc/f2py/oldnews.html'
The path that isn't a directory varies depending on what I'm doing. I tried this through the PyCharm IDE and by running a similar command through the command line, e.g., sudo pip install numpy.
I did see this question, which is similar, but the original poster reinstalled the OS as the solution, which I'd rather not do. I had installed PyCharm using these instructions:
sudo add-apt-repository ppa:mystic-mirage/pycharm
sudo apt-get update
sudo apt-get install pycharm
As with the SO question I linked above, I tried:
pip install headers_workaround
pip install spacy
but I also got that "Not a directory" error with spacy.
When the other person reinstalled their OS I imagine the only thing that really mattered was reinstalling pip.
The instructions to reinstall pip can be found here. Assuming this issue is related to a bug in (your version of) pip running get-pip.py should fix the issue.