Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

python 3.x - pip3 --version ImportError

pip3 --version is throwing an error as of late and I'm having trouble using pip to install packages to my virtual environment. This is a new issue but I think it could be due to having too many python versions installed on my computer.

Has anyone else seen this error thrown? I haven't ever had an error from importlib.util thrown previously. In addition, this error only creeped up lately. To my knowledge I haven't done anything to change importlib.util.

Error processing line 1 of /usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/matplotlib-2.0.2-py3.6-nspkg.pth:

  Traceback (most recent call last):
    File "/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site.py", line 168, in addpackage
      exec(line)
    File "<string>", line 1, in <module>
  AttributeError: module 'importlib.util' has no attribute 'module_from_spec'

Remainder of file ignored
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 11, in <module>
    load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
    return self.resolve()
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.6/site-packages/pip/__init__.py", line 26, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/usr/local/lib/python3.6/site-packages/pip/utils/__init__.py", line 22, in <module>
    from pip.compat import console_to_str, expanduser, stdlib_pkgs
  File "/usr/local/lib/python3.6/site-packages/pip/compat/__init__.py", line 60, in <module>
    from importlib.util import cache_from_source
ImportError: cannot import name 'cache_from_source'
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I'm certain that 'module_from_spec' exists in 3.6. You can actually specify the exact version that your calling pip on, please give that a try :

pip3.6 install packagename

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...