将模块添加到pythonpath - 没有任何作用

时间:2022-07-25 23:11:08

I don't have root access so I installed psycopg2 module to /opt (I have permission for that directory):

我没有root访问权限所以我将psycopg2模块安装到/ opt(我有权访问该目录):

$python setup.py install --prefix=/opt

I've tried several methods:

我尝试了几种方法:

#.bashrc        
PATH=$PATH:$HOME/bin:/opt/lib/python2.4/site-packages/psycopg2/
export PATH  

or

要么

#.bash_profile  
PATH=$PATH:$HOME/bin:/opt/lib/python2.4/site-packages/
export PATH

I also tried sys.path.append('/opt/lib/python2.4/site-packages/psycopg2/')

我也试过sys.path.append('/ opt / lib / python2.4 / site-packages / psycopg2 /')

nothing works:

没有用:

$python  
>>>import psycopg2
>>>no psycopg2 module

Neither /opt/lib/python2.4/site-packages/psycopg2/ or /opt/lib/python2.4/site-packages/ path works

/opt/lib/python2.4/site-packages/psycopg2/或/opt/lib/python2.4/site-packages/ path都不起作用

Please help, thank you

请帮忙,谢谢

1 个解决方案

#1


16  

Try $PYTHONPATH instead of $PATH in your bash configuration file. For more info look at the official documentation on this topic.

在bash配置文件中尝试$ PYTHONPATH而不是$ PATH。有关更多信息,请查看有关此主题的官方文档。

#1


16  

Try $PYTHONPATH instead of $PATH in your bash configuration file. For more info look at the official documentation on this topic.

在bash配置文件中尝试$ PYTHONPATH而不是$ PATH。有关更多信息,请查看有关此主题的官方文档。