如何在OSX中将hashlib安装到python2.7的备用位置?

时间:2019-06-12 06:32:27

标签: python python-2.7 pip

我想将库安装在本地目录lib中。

我跑了pip install hashlib -t lib

这是结果

Collecting hashlib
  Using cached https://files.pythonhosted.org/packages/74/bb/9003d081345e9f0451884146e9ea2cff6e4cc4deac9ffd4a9ee98b318a49/hashlib-20081119.zip
    ERROR: Complete output from command python setup.py egg_info:
    ERROR: Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/antkong/dev/mycompany/my-project-venv/lib/python2.7/site-packages/setuptools/__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, map
      File "/Users/antkong/dev/mycompany/my-project-venv/lib/python2.7/site-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/Users/antkong/dev/mycompany/my-project-venv/lib/python2.7/site-packages/pkg_resources/__init__.py", line 36, in <module>
        import email.parser
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/parser.py", line 12, in <module>
        from email.feedparser import FeedParser
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/feedparser.py", line 27, in <module>
        from email import message
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py", line 16, in <module>
        import email.charset
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/charset.py", line 13, in <module>
        import email.base64mime
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/base64mime.py", line 40, in <module>
        from email.utils import fix_eols
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/utils.py", line 27, in <module>
        import random
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/random.py", line 49, in <module>
        import hashlib as _hashlib
      File "hashlib.py", line 115, in <module>
        f()
    TypeError: 'frozenset' object is not callable
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/d_/y12s1m0j49vff0hf_b1lzgdr0000gn/T/pip-install-sUTnPi/hashlib/

most relevant answer on SO(在撰写此问题时)建议删除以下文件

/Library/Python/2.7/site-packages/hashlib-20081119-py2.7-macosx-10.11-intel.egg

但是该文件在Mojave 10.14.5上不存在

该如何解决?

1 个答案:

答案 0 :(得分:0)

hashlib从Python 2.5开始是standard moduleThe module that you have installed过时且过时,您不应该安装它。

尝试将其卸载:

pip uninstall hashlib

如果未卸载,请手动将其删除。尝试在/Users/antkong/dev/mycompany/my-project-venv/lib/python2.7/site-packages上找到它。