pipenv不适用于“ ModuleNotFoundError:没有名为'pkg_resources'的模块”

时间:2019-02-10 20:58:20

标签: python pipenv pkg-resources

在Mac OS更新到Mojave 10.14.3(可能不相关)之后,所有的pipenv命令现在都可以使用了(几天前,它运行良好)。

seohuns-MBP-2:sparse_tutorial seohun$ pipenv --version
Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/2018.11.26/libexec/bin/pipenv", line 6, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'

seohuns-MBP-2:sparse_tutorial seohun$ pipenv --python 3.6
Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/2018.11.26/libexec/bin/pipenv", line 6, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'

seohuns-MBP-2:sparse_tutorial seohun$ python --version
Python 3.6.8 :: Anaconda custom (64-bit)

搜索此问题时,我发现setuptools中有pkg_resources软件包。因此,我更新了设置工具

seohuns-MBP-2:sparse_tutorial seohun$ pip install --upgrade setuptools
Collecting setuptools
  Downloading https://files.pythonhosted.org/packages/d1/6a/4b2fcefd2ea0868810e92d519dacac1ddc64a2e53ba9e3422c3b62b378a6/setuptools-40.8.0-py2.py3-none-any.whl (575kB)
    100% |████████████████████████████████| 583kB 12.6MB/s 
Installing collected packages: setuptools
  Found existing installation: setuptools 40.6.2
    Uninstalling setuptools-40.6.2:
      Successfully uninstalled setuptools-40.6.2
Successfully installed setuptools-40.8.0

但“ pipenv --version”结果相同。

所以我尝试卸载并安装setuptools

seohuns-MBP-2:sparse_tutorial seohun$ pip uninstall setuptools
Uninstalling setuptools-40.8.0:
  Would remove:
    /anaconda3/bin/easy_install
    /anaconda3/bin/easy_install-3.6
    /anaconda3/lib/python3.6/site-packages/easy_install.py
    /anaconda3/lib/python3.6/site-packages/pkg_resources/*
    /anaconda3/lib/python3.6/site-packages/setuptools-40.8.0.dist-info/*
    /anaconda3/lib/python3.6/site-packages/setuptools/*
Proceed (y/n)? y
  Successfully uninstalled setuptools-40.8.0
seohuns-MBP-2:sparse_tutorial seohun$ pip install setuptools
Requirement already satisfied: setuptools in /anaconda3/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg (40.8.0)

为什么“我已经卸载了setuptools”,但“已经满足要求:/anaconda3/lib/python3.6/site-packages/setuptools-40.8.0-py3.6.egg(40.8.0)中的setuptools”?因此,我尝试在Finder中删除setuptools-40.8.0-py3.6.egg目录,但是我无法删除它,因为它受到了保护。我怀疑这可能是pkg_resources错误的原因。

我还尝试了 pipenv run pip install --force-reinstall setuptools

Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/2018.11.26/libexec/bin/pipenv", line 6, in <module>
    from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'

但不起作用,因为所有pipenv命令均已失效。

所以我卸载并安装pipenv,

seohuns-MBP-2:sparse_tutorial seohun$ pip uninstall pipenv
Uninstalling pipenv-2018.11.26:
  Would remove:
    /Users/seohun/.local/bin/pipenv
    /Users/seohun/.local/bin/pipenv-resolver
    /Users/seohun/.local/lib/python3.6/site-packages/pipenv-2018.11.26.dist-info/*
    /Users/seohun/.local/lib/python3.6/site-packages/pipenv/*
Proceed (y/n)? y
  Successfully uninstalled pipenv-2018.11.26
seohuns-MBP-2:sparse_tutorial seohun$ pip install pipenv
Collecting pipenv
  Using cached https://files.pythonhosted.org/packages/13/b4/3ffa55f77161cff9a5220f162670f7c5eb00df52e00939e203f601b0f579/pipenv-2018.11.26-py3-none-any.whl
Requirement already satisfied: virtualenv-clone>=0.2.5 in /Users/seohun/.local/lib/python3.6/site-packages (from pipenv) (0.4.0)
Requirement already satisfied: setuptools>=36.2.1 in /anaconda3/lib/python3.6/site-packages (from pipenv) (40.8.0)
Requirement already satisfied: virtualenv in /Users/seohun/.local/lib/python3.6/site-packages (from pipenv) (16.4.0)
Requirement already satisfied: pip>=9.0.1 in /anaconda3/lib/python3.6/site-packages (from pipenv) (19.0.2)
Requirement already satisfied: certifi in /anaconda3/lib/python3.6/site-packages (from pipenv) (2018.10.15)
Installing collected packages: pipenv
Successfully installed pipenv-2018.11.26

,但是pipenv命令仍然不起作用。我尝试了“ sudo chown seohun easy-install.pth ”,但是

chown: easy-install.pth: No such file or directory

接下来,我按照堆栈溢出答案尝试了 pip install ez_setup,pip installly,easy_install -U setuptools,pip3 install --upgrade virtualenv ,它们都可以正常工作,但是pipenv命令仍然不起作用。 BTW pipenv已连接到Python3。

seohuns-MBP-2:sparse_tutorial seohun $其中python / anaconda3 / bin / python

有什么可以尝试的吗?

0 个答案:

没有答案