Where is the Python module installation directory?

Source: Internet
Author: User

One of the important reasons for Python's strength is that python has a rich library (module) that makes it easier to handle a wide variety of problems. Python - developed third-party modules are generally installed on 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,Python 's own build-in modules are typically located in:/usr/lib/ Pythonx.y/site-packages

The command to install the 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 add parameters to the command:–user, Or–home, Or–prefix and– exec -prefix, Or–install-base and–install-platbase, etc. to specify the installation path.

It should be noted that the installation path of the module must be in the sys.path list , in order to be able to import in the script normally .

Python http:// Docs.python.org/3.3/install/index.html#how-installation-works

debian series (including ubuntu Linux DIST-PACKAGES  SITE-PACKAGES  directory; debian http://wiki.debian.org/python#deviations_from_upstream

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

# on a RHEL6.3 x86-64 system

[Email protected] ~]# cat/etc/issue

Red Hat Enterprise Linux Server release 6.3 (Santiago)

Kernel \ r on an \m

[Email protected] ~]# ls/usr/lib/python2.6/site-packages/

[Email protected] ~]# ls/usr/lib64/python2.6/site-packages/

[Email protected] ~]# ls/usr/local/lib64/python2.6/site-packages/

# Switch to an Ubuntu x86-64 system

[Email protected]:~$ cat/etc/issue

Ubuntu 12.04.1 LTS \ \l

[Email protected]:~$ ls/usr/lib/python2.7/dist-packages/

[Email protected]:~$ ls/usr/local/lib/python2.7/dist-packages/

Easy-installnanh Mysql_connector_repackaged-0.3.1-py2.7.egg

[Email protected]:~$ 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 ']

>>>


Where is the Python module installation directory?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.