0

我的 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。

谢谢!

4

1 回答 1

1

感谢在stackoverflow上发布的其他人,我发现了如何解决这个问题。简而言之,在 PyDev - Interpreter/Grammar 下的项目属性中添加“六个”> 单击此处配置和未列出的解释器 > Forced Builtins > New ...

Eclipse 花了几分钟来处理更改,最终成功了。

这里有帮助的帖子: Eclipse-Pydev 找不到 Lucene 库

于 2016-04-28T13:48:33.073 回答