Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Where is the installation directory for the python module?

Shulou Source: shulou.com Published: 2022-05-31 23:51:46 10月02日 Update

This article mainly shows you the "python module installation directory where", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "where the python module installation directory is" this article.

One of the important reasons for the power of Python is that Python has a rich library (module) so that it can easily deal with a variety of problems. Third-party modules developed by Python is generally installed in some fixed paths, as follows:

Unix (Linux): prefix/lib/pythonX.Y/site-packages default path: / usr/local/lib/pythonX.Y/site-packages

Windows: prefix\ Lib\ site-packages default path: C:\ PythonXY\ Lib\ site-packages

In addition, on Unix-like systems, the build-in module of Python itself is generally located at: / usr/lib/pythonX.Y/site-packages

The command to install a module from the source code is generally: setup.py install

Of course, you can change the default third-party module installation path as needed, and you can specify the installation path by adding parameters such as-user, or-home, or-prefix and-exec-prefix, or-install-base and-install-platbase, etc.

It is important to note that the installation path of the module must be in the sys.path List before it can be properly import in the script.

On the installation of the module, the official reference document of Python is: http://docs.python.org/3.3/install/index.html#how-installation-works

In addition, on the Linux of the Debian series (including Ubuntu), dist-packages is generally used instead of the site-packages directory; this is also explained on the website of the Debian project, which can be found at: http://wiki.debian.org/Python#Deviations_from_upstream

Here are some paths to the Python module that I see on my system:

# on a RHEL6.3 x86-64 system

[root@jay-linux ~] # cat / etc/issue

Red Hat Enterprise Linux Server release 6.3 (Santiago)

Kernel\ r on an\ m

[root@jay-linux ~] # ls / usr/lib/python2.6/site-packages/

[root@jay-linux ~] # ls / usr/lib64/python2.6/site-packages/

[root@jay-linux ~] # ls / usr/local/lib64/python2.6/site-packages/

# switch to a Ubuntu x86-64 system

Master@jay-intel:~$ cat / etc/issue

Ubuntu 12.04.1 LTS\ n\ l

Master@jay-intel:~$ ls / usr/lib/python2.7/dist-packages/

Master@jay-intel:~$ ls / usr/local/lib/python2.7/dist-packages/

Easy-installNaNh mysql_connector_repackaged-0.3.1-py2.7.egg

Master@jay-intel:~$ python3

Python 3.2.3 (default, Oct 19 2012, 20:10:41)

[gcc 4.6.3] on linux2

Type "help", "copyright", "credits" or "license" for more information.

> import sys

> sys.path

['', / usr/local/lib/python3.2/dist-packages/mysql_connector_repackaged-0.3.1-py3.2.egg','/ usr/lib/python3.2','/ usr/lib/python3.2/plat-linux2','/ usr/lib/python3.2/lib-dynload','/ usr/local/lib/python3.2/dist-packages','/ usr/lib/python3/dist-packages']

> > >

The above is all the contents of the article "where is the installation directory of the python module". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Modules paths directories systems content articles commands third parties learning help powerful important reasons parameters various official documentation easy to understand more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology OPPO Reno Docker NVidia