我有一台 Windows 7 64 位机器,想要安装 python 包 mgrs。我尝试使用 easy_install 并在 mgrs 目录中运行 python setup.py install 。 Easy_install 给我以下错误。
C:\Users\farrell>easy_install mgrs
Searching for mgrs
Reading https://pypi.python.org/simple/mgrs/
Best match: mgrs 1.1.0
Downloading https://pypi.python.org/packages/source/m/mgrs/mgrs-1.1.0.tar.gz#md5
=96e0c00f16d86a3f8b84c2c46cb68b8e
Processing mgrs-1.1.0.tar.gz
Writing c:\users\farrell\appdata\local\temp\easy_install-lzqjsi\mgrs-1.1.0\setup
.cfg
Running mgrs-1.1.0\setup.py -q bdist_egg --dist-dir c:\users\farrell\appdata\loc
al\temp\easy_install-lzqjsi\mgrs-1.1.0\egg-dist-tmp-sxkdib
Traceback (most recent call last):
File "C:\Python27\Anaconda\Scripts\easy_install-script.py", line 9, in <module
>
load_entry_point('setuptools==5.4.1', 'console_scripts', 'easy_install')()
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 2147
, in main
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 2133
, in with_ei_usage
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 2150
, in <lambda>
File "C:\Python27\Anaconda\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\Anaconda\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\Anaconda\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 370,
in run
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 613,
in easy_install
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 643,
in install_item
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 833,
in install_eggs
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1055
, in build_and_install
File "build\bdist.win-amd64\egg\setuptools\command\easy_install.py", line 1040
, in run_setup
File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 63, in run_setup
File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 109, in run
File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 62, in runner
File "build\bdist.win-amd64\egg\setuptools\sandbox.py", line 38, in _execfile
File "c:\users\farrell\appdata\local\temp\easy_install-lzqjsi\mgrs-1.1.0\setup
.py", line 8, in <module>
ImportError: cannot import name Library
setup.py 的第 8 行是 从 setuptools 导入库作为扩展
对于导致问题的原因有什么帮助吗?
最佳答案
在旧版本的 setuptools 中,Library
类被导入到 setuptools
包中。自 1.1 版本以来就不再出现这种情况。
该 setup.py 脚本是针对比您安装的旧版本的 setuptools 编写的。
您应该能够通过编辑 setup.py 并将导入更改为来修复它:
from setuptools.extension import Library
安装后
对于 Windows 中的这个特定包,它似乎将构建的 DLL 安装到 site-packages 目录中。安装后,编辑 mgrs\core.py
并替换行:
local_dlls = os.path.abspath(os.__file__ + "../../../DLLs")
与:
import site
local_dlls = ";".join(site.getsitepackages())
关于python 安装工具 : ImportError: cannot import name Library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24612021/