Pip安装不断抛出奇怪的“ImportError”


1

我一直在尝试使用pip安装一些软件包并pyudev不断抛出导入错误。我不知道为什么它只发生在pyudev。它在我的其他计算机上安装得很好。这是命令和输出:

$ sudo pip install pyudev

Collecting pyudev
  Downloading pyudev-0.16.1.tar.gz (74kB)
    100% |################################| 77kB 882kB/s 
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-1Pk9rC/pyudev/setup.py", line 55, in <module>
    packages=setuptools.find_packages(),
      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
      File "<string>", line 12, in replacement_run
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2310, in load
    return self.resolve()
      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2316, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
    ImportError: No module named version
    Complete output from command python setup.py egg_info:
    running egg_info

    creating pip-egg-info/pyudev.egg-info

    Traceback (most recent call last):

      File "<string>", line 20, in <module>

      File "/tmp/pip-build-1Pk9rC/pyudev/setup.py", line 55, in <module>

    packages=setuptools.find_packages(),

      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup

    dist.run_commands()

      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands

    self.run_command(cmd)

      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

      File "<string>", line 12, in replacement_run

      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2310, in load

    return self.resolve()

      File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2316, in resolve

    module = __import__(self.module_name, fromlist=['__name__'], level=0)

    ImportError: No module named version

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-1Pk9rC/pyudev

更新:当我更多地挖掘时,我注意到在我的另一台计算机上它并没有尝试安装“版本”。

UPDATE2:嗯,我不知道为什么会发生这种情况,但它是python-daemon包的东西。这是另一个具有相同问题的用户。https://stackoverflow.com/questions/27972349/installing-latest-python-daemon-2-0-3-breaks-subsequent-pip-installs

Update3:刚刚意识到我没有提到卸载python-daemon修复了这个问题。这是一个旧的依赖,我不再需要它。最新版本导致此问题。


适用于我pip uninstall python-daemon -y; pip install python-daemon==2.0.2 stackoverflow.com/questions/27972349 / ...
rofrol 2015年

Answers:


0

首先尝试升级pip本身。

pip install -U pip

我做到了 没有帮助。当这不起作用时,我升级了pip并升级了setuptools。
amustafa 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.