ImportError:尝试在ubuntu上安装arosics时无法导入名称util

时间:2018-03-08 02:21:35

标签: python linux python-2.7 ubuntu ubuntu-16.04

尝试在ubuntu 16.04 LTS上安装AROSICS(https://pypi.python.org/pypi/arosics/0.8.2)时。

当我这样做时:

~$ sudo pip install arosics

然后我得到:

The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting arosics
  Downloading arosics-0.8.4.tar.gz (21.9MB)
    100% |################################| 21.9MB 32kB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-PRYU7V/arosics/setup.py", line 8, in <module>
        from importlib import util
    ImportError: cannot import name util

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

也尝试过:

sudo -H pip install arosics
Collecting arosics
  Downloading arosics-0.8.4.tar.gz (21.9MB)
    100% |################################| 21.9MB 23kB/s 
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-cTU5Br/arosics/setup.py", line 8, in <module>
        from importlib import util
    ImportError: cannot import name util

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

我不确定出了什么问题。我尝试了pip install python-util但事件之后我一直收到同样的错误。

请问如何继续?

2 个答案:

答案 0 :(得分:0)

Arosics目前只适用于Python3。 from importutil import util在Python 2.7下不起作用,因为它不受支持。

如果选择切换到Python3是一个很好的选择。如果没有,则必须修改Arosics项目的setup.py。

我能够使用sudo pip3 install arosics

成功安装

答案 1 :(得分:0)

此问题已在0.8.14版的Arosics中修复。现在它应该再次兼容Python 2.7。

但是,选择Python 3!