![]() Unlike the current accepted answer, this method still works regardless of whether or not you have a virtual environment active. Requires: more-itertools, atomicwrites, setuptools, attrs, pathlib2, six, py, pluggyĪ modern stdlib way is using sysconfig module, available in version 2.7 and 3.2+. ![]() Summary: pytest: simple powerful testing with PythonĪuthor: Holger Krekel, Bruno Oliveira, Ronny Pfannschmidt, Floris Bruynooghe, Brianna Laugher, Florian Bruhin and others Run pip show to show Debian-style package information: $ pip show pytest _file_ lets you identify the location of a specific module: ( difference) $ python3 -c "import os as _ print(_._file_)" _path_ lets you identify the location(s) of a specific package: ( details) $ python -c "import setuptools as _ print(_._path_)" ![]() Hint: Running pip list -user or pip freeze -user gives you a list of all installed per user site-packages. If this points to a non-existing directory check the exit status of Python and see python -m site -help for explanations. ![]() The per user site-packages directory ( PEP 370) is where Python installs your local packages: python -m site -user-site ![]() In Python 3, you may use the sysconfig module instead: python3 -c 'import sysconfig print(sysconfig.get_paths())' Global site-packages (" dist-packages") directories are listed in sys.path when you run: python -m siteįor a more concise list run getsitepackages from the site module in Python code: python -c 'import site print(site.getsitepackages())'Ĭaution: In virtual environments getsitepackages is not available with older versions of virtualenv, sys.path from above will list the virtualenv's site-packages directory correctly, though. There are two types of site-packages directories, global and per user. ![]()
0 Comments
Leave a Reply. |