转载请注明出处:

http://www.cnblogs.com/darkknightzh/p/5896446.html

参考网址:

http://www.th7.cn/Program/Python/201510/641841.shtml

http://stackoverflow.com/questions/33371954/pycharm-import-caffe-error/33397590

http://askubuntu.com/questions/684550/importing-a-python-module-works-from-command-line-but-not-from-pycharm

 

http://www.th7.cn/Program/Python/201510/641841.shtml中说使用sys.path.append实际上可用:

import sys
sys.path.append("/home/xxx/project/caffe-master/python")

 

http://stackoverflow.com/questions/33371954/pycharm-import-caffe-error/33397590说修改/etc/ld.so.conf。修改了之后,不管用。但是该网址中图片内已经贴出使用sys.path.insert来增加路径。实际上也是可以的:

import sys
sys.path.insert(0, "/home/xxx/project/caffe-master/python")

 

http://askubuntu.com/questions/684550/importing-a-python-module-works-from-command-line-but-not-from-pycharm中Mihai Capotă指出,由于pycharm并不读取.bashrc中的内容,因而在命令行中能使用import python,但是pycharm中依旧不能使用python。解决方法是:As an alternative to setting the paths in PyCharm, you can simply start PyCharm from a Bash shell to give it access to the environment variables you set in .bashrc.(从bash shell中启动pycharm,使pycharm能读取.bashrc中的环境变量)——这个没试过