"Go" python modifies OS environment variables

Source: Internet
Author: User
Tags gtk

To give a very simple example, if you find a package or module, there is obviously, but this error will occur:

>>> from algorithm Import *
Traceback (most recent):
File "<stdin>", line 1, in <module>
Importerror:no module named algorithm

Then there's the problem with the environmental variables.

Okay, let's see how.

>>>>> Import Sys
>>> Sys.path
[', '/usr/lib/python2.7 ', '/usr/lib/python2.7/plat-linux2 ', '/usr/lib/python2.7/lib-tk ', '/usr/lib/python2.7/ Lib-old ', '/usr/lib/python2.7/lib-dynload ', '/usr/local/lib/python2.7/dist-packages ', '/usr/lib/python2.7/ Dist-packages ', '/usr/lib/python2.7/dist-packages/pil ', '/usr/lib/python2.7/dist-packages/gst-0.10 ', '/usr/lib/ python2.7/dist-packages/gtk-2.0 ', '/usr/lib/pymodules/python2.7 ', '/usr/lib/python2.7/dist-packages/ Ubuntu-sso-client ', '/usr/lib/python2.7/dist-packages/ubuntuone-client ', '/usr/lib/python2.7/dist-packages/ Ubuntuone-control-panel ', '/usr/lib/python2.7/dist-packages/ubuntuone-couch ', '/usr/lib/python2.7/dist-packages/ Ubuntuone-installer ', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol ']

First, these show Python's own environment variables

And then

>>> sys.path.append ('/media/file/code_downloadcodeandselfcode/pyworkplace/xview ')
>>> Sys.path
[', '/usr/lib/python2.7 ', '/usr/lib/python2.7/plat-linux2 ', '/usr/lib/python2.7/lib-tk ', '/usr/lib/python2.7/ Lib-old ', '/usr/lib/python2.7/lib-dynload ', '/usr/local/lib/python2.7/dist-packages ', '/usr/lib/python2.7/ Dist-packages ', '/usr/lib/python2.7/dist-packages/pil ', '/usr/lib/python2.7/dist-packages/gst-0.10 ', '/usr/lib/ python2.7/dist-packages/gtk-2.0 ', '/usr/lib/pymodules/python2.7 ', '/usr/lib/python2.7/dist-packages/ Ubuntu-sso-client ', '/usr/lib/python2.7/dist-packages/ubuntuone-client ', '/usr/lib/python2.7/dist-packages/ Ubuntuone-control-panel ', '/usr/lib/python2.7/dist-packages/ubuntuone-couch ', '/usr/lib/python2.7/dist-packages/ Ubuntuone-installer ', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol ', '/media/File/Code_ Downloadcodeandselfcode/pyworkplace/xview/emotionanalyse ', '/media/file/code_downloadcodeandselfcode/ Pyworkplace/xview ']
>>> Import algorithm

In this way, I have imported my algorithm into this package.

It's OK!

But there is a problem, the next time you have to set up.

Then change the system variable:

$export pythonpath= $PYTHONPATH:/home/yourselfpath

Pro-Test Effective ~

"Go" python modifies OS environment variables

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.