简体   繁体   中英

Python packages installing in the wrong folder

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM