我的 PyDev Eclipse 项目只有一个文件,其中包含以下四行:
import os
from six.moves.urllib.request import urlretrieve
from six.moves import cPickle as pickle
print("OK")
Eclipse 报告了这些“问题”:
Unresolved import: pickle main.py /1_notminst line 2 PyDev Problem
Unresolved import: urlretrieve main.py /1_notminst line 1 PyDev Problem
但是,Eclipse 运行程序没有任何问题,并从命令行打印“OK”以及 python3(或 ipython3):
> python3 main.py
OK
知道为什么 Eclipse+PyDev 的编辑器看不到那个库吗?它是 Python 六库。pip3 报告库已安装:
> pip3 show six
---
Metadata-Version: 1.1
Name: six
Version: 1.10.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /usr/lib/python3/dist-packages
Requires:
Classifiers:
Programming Language :: Python :: 2
Programming Language :: Python :: 3
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Topic :: Software Development :: Libraries
Topic :: Utilities
导入其他库就好了。
我在 Ubuntu 16.04 和 Python 3.5 下运行 Eclipse Mars。
谢谢!