您可能需要检查系统上安装的DILL版本。0.2A1之前的版本(特别是0.1A1版本)不包含“objects”,会引发上面看到的错误。
我在我的Mac上创建了一个测试Conda环境,并尝试通过PIP安装使用各种版本的dill进行失败的导入。
DILL版本0.1A1的结果:
(dill_test) pip install dill==0.1a1
Collecting dill==0.1a1
Installing collected packages: dill
Successfully installed dill-0.1a1
(dill_test) python
Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 13:10:39)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
>>> from dill import objects
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name objects
DILL版本为0.2A1或更高版本的结果(导入对象时无错误):
(dill_test) pip uninstall dill
Uninstalling dill-0.1a1:
Would remove:
/Users/.../anaconda2/envs/dill_test/lib/python2.7/site-packages/dill- 0.1a1.dist-info/*
/Users/.../anaconda2/envs/dill_test/lib/python2.7/site-packages/dill/*
Proceed (y/n)? y
Successfully uninstalled dill-0.1a1
(dill_test) pip install dill==0.2a1
Collecting dill==0.2a1
Installing collected packages: dill
Successfully installed dill-0.2a1
(dill_test) python
Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 13:10:39)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
>>> from dill import objects
>>>
https://pypi.org/project/dill/