我想在我的ubuntu机器(corgy工具)上运行用python编写的第三部分工具。
但是,我不知道如何向Python路径添加额外的模块。
cat doc/download.rst
There is currently no setup.py, so you need to manually add
the download directory to your PYTHON_PATH environment variable.如何将目录添加到PYTHON_PATH?
我试过了:
export PYTHON_PATH=/home/user/directory:$PYTHON_PATH && source .bashrc
export PATH=/home/user/directory:$PATH && source .bashrc
python
import sys
sys.path.append("/home/user/directory/")
但是当我尝试运行这个工具时,我得到:
Traceback (most recent call last):
File "examples/dotbracket_to_bulge_graph.py", line 4, in <module>
import corgy.graph.bulge_graph as cgb
ImportError: No module named corgy.graph.bulge_graph发布于 2013-06-04 08:34:42
在主目录中创建一个.bash_profile。然后,添加行
PYTHONPATH=$PYTHONPATH:new_dir
EXPORT $PYTHONPATH甚至更好:
if [ -d "new_dir" ] ; then
PYTHONPATH="$PYTHONPATH:new_dir"
fi
EXPORT $PYTHONPATH每次登录时都会加载.bash_profile属性。
如果您不想再次登录,source命令非常有用。
发布于 2021-02-09 12:13:32
@fedorqui上面的回答对我来说几乎是好的,但至少有一个错误(我不确定export语句的所有大写,我是一个完全的新手)。出口声明中不应该在PYTHONPATH之前有一个$标志。所以选择如下:
在主目录中创建一个.bash_profile。然后,添加行 PYTHONPATH=$PYTHONPATH:new_dir出口产品 甚至更好: 如果-d "new_dir“;那么PYTHONPATH="$PYTHONPATH:new_dir”fi出口PYTHONPATH
https://stackoverflow.com/questions/16913086
复制相似问题