Determine the Site-packages directory location in the current Python environment

Source: Internet
Author: User

The concept of "search path" is introduced because when an import statement is used, when the interpreter encounters an import statement, the module is imported if it is in the current search path.

A search path is a list of all directories that an interpreter will search first.

So how does python add a module search path? One recommended approach is to add a path file, such as Mypkpath.pth, to the Site-packages,

You must use the. PTH suffix to write the directory name of the module file you want to add.

Here's the question to solve now: "How to determine the Site-packages directory location in the current Python environment." Note: This method only applies to version 2.7.

>>>import site; Site.getsitepackages ()

Determine the Site-packages directory location in the current Python environment

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.