Make your own Python module available

Source: Internet
Author: User

How do I make a module that I write available? Three ways:

Put it in the right place.


For example, drop the Python module you wrote in the Dist-packages directory.

Add a lookup directory for the Interpreter


We have added our own created directory/root/python to the interpreter's lookup directory
The problem with this method is that when we reopen the interpreter, the previously added directory disappears

To add an environment variable:

You can use the export PYTHONPATH=$PYTHONPATH:~/python Python folder in the current user directory to add to the environment variable
However, if you use this command in terminal, it is only valid in this terminal, not in the other terminal
Place this command in the. bashrc file in the current user directory, and each time a new shell is started, the commands in this file will be executed

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Make your own Python module available

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.