导入错误,没有名为zlib的模块(已安装python的brew)
当我在python 2.7的brew安装版本上使用pip Frozen时,出现导入错误,没有名为zlib的模块.
When I use pip freeze on the brew installed version of python 2.7 I get an import error no module named zlib.
➜ ~ pip freeze
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==7.1.2', 'console_scripts', 'pip')()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 558, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2682, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2355, in load
return self.resolve()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2361, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/local/lib/python2.7/site-packages/pip/__init__.py", line 15, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python2.7/site-packages/pip/vcs/mercurial.py", line 10, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 38, in <module>
from pip._vendor import requests, six
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/__init__.py", line 58, in <module>
from . import utils
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/utils.py", line 26, in <module>
from .compat import parse_http_list as _parse_list_header
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/compat.py", line 7, in <module>
from .packages import chardet
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/__init__.py", line 3, in <module>
from . import urllib3
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/__init__.py", line 10, in <module>
from .connectionpool import (
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 38, in <module>
from .response import HTTPResponse
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/response.py", line 5, in <module>
import zlib
ImportError: No module named lib
我认为这通常是在python中安装的,但是我已经在brew中安装了python(2.7),并且通过brew重新安装并重新安装不能解决问题?
I think this is normally installed with python but I've installed python (2.7) with brew and an uninstall and reinstall with brew doesn't fix the issue?
➜ ~ which pip
/usr/local/bin/pip
➜ ~ which python
/usr/local/bin/python
这是xcode无法正确安装zlib的问题.
This is an issue with xcode not installing zlib properly.
使用以下命令安装xcode CLI:
Install the xcode CLI with:
xcode-select --install
然后在用brew重新安装Python之前,我检查zlib标头是否是brew通过终端在寻找它的地方:
Then before reinstalling Python with brew I check if the zlib header is where brew is looking for it via the terminal :
ls /usr/include/zlib.h
然后通过brew重新安装python:
Then reinstall python via brew:
brew reinstall python