Eclipse + Pydev开发Python时import报错解决方法

时间:2021-07-16 15:59:48
用eclipse +PyDev开发python时,需要import其他文件时eclipse会报错,但是在python的命令行中运行却没有问题。 据人分析其实发生错误的原因是在Preferences->Pydev->Interpreter-Python中的SystemPYTHONPATH 引用不完全,不知道你发现没有,在python3.1中的SystemPYTHONPATH比在python2.x中的少很多,而在python2.x中就不会出现类似的import错误。 ------------------------------------------------------------------------------------------------------------------ 下面是问题的解决方法:
1.右键工程——properties 2.选择Pydev-Interface/Grammar,点击链接Click here to configure aninterpreter not listed 3.在python Interperter中选择New Folder,添加文件的父目录即可。