How do I find the location of my Python site-packages directory?

How do I find the location of my Python site-packages directory?

Your answer

  1. Global site-packages (“dist-packages”) directories are listed in sys.path when you run: python -m site.
  2. The per user site-packages directory (PEP 370) is where Python installs your local packages: python -m site –user-site.

How do I tell which version of Python I have?

Check the Python version on the command line: –version, -V, -VV. Execute the python or python3 command with the –version or -V option on the command prompt on Windows or the terminal on Mac.

How to find the location of my Python site packages directory?

How do I find the location of my Python site-packages directory? Python Server Side Programming Programming. You can find the location of Python site-packages directory by using the site module in the following way −. >>> import site >>> site.getsitepackages () [‘/usr/local/lib/python2.7/dist-packages’, ‘/usr/lib/python2.7/dist-packages’]

How to configure Python to use additional locations?

You can use the Site-specific configuration hook. “A path configuration file is a file whose name has the form name.pth and exists in one of the four directories mentioned above; its contents are additional items (one per line) to be added to sys.path .”

How to add site packages to Python 2.7?

To get around this I created a symbolic link in /opt/python2.7.2/lib/python2.7/site-packages to the location of this third party application: This appears to work fine but I’m wondering if there’s a better way? You can use the Site-specific configuration hook.

What is a path configuration file in Python?

“A path configuration file is a file whose name has the form name.pth and exists in one of the four directories mentioned above; its contents are additional items (one per line) to be added to sys.path .” In your case, you should be able to achieve what you want by simply dropping in a .pth file containing the path of the directory to include: