繁体   English   中英

Mac上的Python / PIP软管

[英]Python / PIP on Mac hosed

我认为Python的系统安装可以。 我可以轻松地从bash打开python shell。 但是,PIP已不再。 我也在尝试运行Ansible,但是那只是退出了工作。

我正在做的是尝试解决模块安装但无法导入的问题。 我先卸载然后重新安装,这解决了我的大多数问题,然后一切都崩溃了。

问题1:PIP不见了。 PIP显示“找不到命令”。 那么也许符号链接消失了? 我尝试通过https://pip.readthedocs.io/en/latest/installing/重新安装并获得以下信息:

Traceback (most recent call last):
  File "get-pip.py", line 28, in <module>
    import tempfile
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 32, in <module>
    import io as _io
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/io.py", line 51, in <module>
    import _io
ImportError: dlopen(/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyCodecInfo_GetIncrementalDecoder
  Referenced from: /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so
  Expected in: flat namespace
 in /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_io.so

尝试使用easy_install时,出现以下错误:

Traceback (most recent call last):
  File "/usr/bin/easy_install-2.7", line 11, in <module>
    load_entry_point('setuptools==18.5', 'console_scripts', 'easy_install')()
  File "/Users/farroar/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 484, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Users/farroar/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2725, in load_entry_point
    return ep.load()
  File "/Users/farroar/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2343, in load
    return self.resolve()
  File "/Users/farroar/Library/Python/2.7/lib/python/site-packages/pkg_resources/__init__.py", line 2349, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 46, in <module>
    from setuptools.archive_util import unpack_archive
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/archive_util.py", line 15, in <module>
    from pkg_resources import ensure_directory, ContextualZipFile
ImportError: cannot import name ContextualZipFile

-a python给出了:

/usr/local/bin/python
/usr/bin/python

我用brew安装了python并重新安装,但在此过程中收到错误:

error: could not delete '/usr/local/lib/python2.7/site-packages/pip/_internal/configuration.py': Permission denied
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall python@2`

当我尝试在不假设root的情况下运行ansible时,出现一个奇怪的错误:

.....
", line 18, in <module>
    from cryptography.x509.name import Name
  File "/usr/local/lib/python2.7/site-packages/cryptography/x509/name.py", line 28, in <module>
    _ASN1_TYPE_TO_ENUM = dict((i.value, i) for i in _ASN1Type)
TypeError: 'type' object is not iterable

我希望在这里有方向。 一切工作正常,直到遇到无法加载的模块。 追到一个洞里。

  1. RUN: which pip

  2. 您是否使用brew安装了Python。 如果您这样做了,请brew doctor查看是否存在未链接的文件。

  3. 尝试直接使用python2运行您的应用程序。

有时候,如果您用足够长的时间敲击它,它只会让步。我再次卸载了brew python安装程序。 在那之后,我能够安装pip。 都很奇怪 冲泡的东西弄乱了一切。

我真的需要用brew作为python吗? 我只是在猜测是否需要使用2.7.10以外的版本,对吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM