如何在Mac上编辑PYTHONPATH? [英] How can I edit PYTHONPATH on a Mac?
本文介绍了如何在Mac上编辑PYTHONPATH?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在Mac上永久更改PYTHONPATH?我尝试编辑.bash_profile,但是当我在文件中使用print sys.path
时,它会提供比.bash_profile更大的不同URL列表.在终端中,当我键入echo $PYTHONPATH
时,它会显示一个空行.我不想使用sys.path.append('...'),因为那样我就必须将它放在每个文件中.
How can I permanently change the PYTHONPATH on a mac? I've tried editing .bash_profile, but when I use print sys.path
in a file it gives a huge list of different URLs than the .bash_profile. In Terminal when I type echo $PYTHONPATH
it shows a blank line. I don't want to use sys.path.append('...') because then I have to put that in every file.
推荐答案
-
您可以将路径附加到
$PATH
而不是,如果您坚持要更改PYTHONPATH
,则在某些情况下 可口的:if you insist to change the
PYTHONPATH
, in some context that is prefferable:执行此:
export PYTHONPATH=$PYTHONPATH:/Users/username/pymodules
- 为确保您遵循附加内容的约定
PYTHONPATH
参见 在PYTHONPATH中到底应该设置什么?. - To make sure you are following the convention of what to append to
PYTHONPATH
see What exactly should be set in PYTHONPATH?.
这篇关于如何在Mac上编辑PYTHONPATH?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文