简体   繁体   中英

The site-packages folder exists for python2 but not python3

As the root user I see:

root@5d6f29f1d4e9:/usr/local/lib/python2.7# ls -a
.  ..  dist-packages  site-packages
root@5d6f29f1d4e9:/usr/local/lib/python3.6# ls -a
.  ..  dist-packages

and when I run this:

find / -type d -name 'site-packages'

the only result is:

/usr/local/lib/python2.7/site-packages

does anyone know why I wouldn't see site-packages in 3.6?

I installed python3 with:

 apt install -y build-essential libssl-dev libffi-dev python3-dev
 apt install -y python3-pip

and then installed a bunch of python package using:

 pip3 install gunicorn
 pip3 install wheel
 ...etc...

maybe I didn't install python3 well?

It seems to be Debian feature with dist-packages instead of site-packages. You can check the path for your pip3 installed packages: python3 -c "import wheel;print(wheel.__file__)"

If your goal is to find where the python is installing your packages, then read on.

  1. Just open the python console using python3 .
  2. Check whether you can import your package directly. (When I say directly, I mean without any virtualenv etc) import gunicorn
  3. Now, in the console if it is working without errors, that means your python3 can find the package.
  4. If you think where the python looks for packages, the obvious solution to occur would be to use sys.path
  5. So import sys and then print(sys.path) That should give you a list of folders not more than 10. Just navigate through the folders and you will find the path where packages are installed by default.

OR Simply run python3 -m site

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