轉載請注明出處:
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://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中的環境變量)——這個沒試過。