我知道我可以像这样添加 Python 的导入路径:
import sys
sys.path.append("/path/to/directory/")
但是,当我重新启动 Python 时,这个问题就消失了。如果我必须一直这样做,我会觉得很烦人,我想一劳永逸地做这件事并完成它。
又怎样?我在哪里可以找到该文件?或者我需要编辑其他内容吗?我正在使用最新版本的 Ubuntu。
From 男人 蟒蛇
~/.pythonrc.py
User-specific initialization file loaded by the user module; not used by default or by most applications.
ENVIRONMENT VARIABLES
PYTHONPATH
Augments the default search path for module files. The format is the same as the shell's $PATH: one or more directory pathnames
separated by colons. Non-existent directories are silently ignored. The default search path is installation dependent, but gen-
erally begins with ${prefix}/lib/python<version> (see PYTHONHOME above). The default search path is always appended to $PYTHON-
PATH. If a script argument is given, the directory containing the script is inserted in the path in front of $PYTHONPATH. The
search path can be manipulated from within a Python program as the variable sys.path .
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)