質問

PYTHON 3.3 I have my HDD partitioned with programmes on "C" and data on "D" one NTFS and the other fat32. I've downloaded examples of code from one of the popular manuals onto "D". Running sys.path does not show these. I've looked, but cannot find the sys.path file to permanently add my "path". I can have the sys.path come up in IDLE, but making changes here are only temporary I believe. It is a small irritation to have to "go looking" each time. I'd really appreciate some comments, and apologize if this has already been answered somewhere else.

役に立ちましたか?

解決

You can modify the environment variable PYTHONPATH to adjust the default path Python looks for modules when importing.

他のヒント

For instance, to add the directory /home/me/mypy to the path, just do:

import sys

sys.path.append("/home/me/mypy")

source: http://www.johnny-lin.com/cdat_tips/tips_pylang/path.html

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top