热门标签:
Q:

python setuptools:ImportError:无法导入名称库

我有一台Windows7 64位机器,想安装python包mgrs。 我已经尝试使用easy_install和运行python setup.py 安装在mgrs目录中。 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

第8行setup.py 是 从setuptools导入库作为扩展

有关导致问题的原因的任何帮助?

原网址
A:

在旧版本的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())

所有回答

共 1 条

author avatar

检查并确保安装了最新版本的SetupTools。 以前关于这个问题的帖子与机器上有一个螺旋形的SetupTools版本有关。 此外,您可能想尝试pip而不是easy_install,因为它更好一些。

相似问题