Python adds its own module path, python module path

Source: Internet
Author: User

Python adds its own module path, python module path

After entering the Python editing environment, you can use the sys. path attribute of Python to obtain the current search path configuration. You can see that the previously set path is already in the current search path.

Then, you can use sys. path. append ('f: \ Pythonchengxu ') to add the path you have created.

You can see that the instance is successfully added.

However, note that this method is only temporary. The next time you start the interactive interpreter, sys. path will return to the previous state. If you want to add a search path permanently, you can use the following two methods:

Method 2: Modify Environment Variables
W users can modify the system environment variable PYTHONPATH

Method 3: add the. pth file. recommended!
Add a path file in site-packages, for example, mypkpath. pth, which must be suffixed with. pth. Enter the Directory Name of the module file you want to add.
1 windows
C: \ Python27 \ Lib \ site-packages

Add mypkpath. pth to this directory. The content is the address to be changed.

 

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.