[CentOS] pip freeze 出現 parse error at "'-ipap11h'" 的問題
今天在 CentOS 7 上,想用 pip freeze 看一下目前有安裝的 python 模組,
遇到了奇怪的錯誤訊息,說 Invalid requirement, parse error at “‘-ipap11h'”:
testuser@localhost ~ $ pip freeze Exception: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/lib/python2.7/site-packages/pip/commands/freeze.py", line 85, in run for line in freeze(**freeze_kwargs): File "/usr/lib/python2.7/site-packages/pip/operations/freeze.py", line 47, in freeze dependency_links File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 264, in from_dist req = dist.as_requirement() File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2562, in as_requirement return Requirement.parse(spec) File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2833, in parse req, = parse_requirements(s) File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2781, in parse_requirements yield Requirement(line) File "/usr/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2790, in __init__ raise RequirementParseError(str(e)) RequirementParseError: Invalid requirement, parse error at "'-ipap11h'"
完全看不懂這個錯誤訊息是在做什麼…
後來查到 pip freeze:Invalid requirement, parse error at “‘-ipap11h'” 這篇,
看來是 pip 8.1.2 版本對於模組名稱的處理有變嚴格,
所以遇到像是 -pap11h 這個模組名稱就會掛掉了…
看一下現在的 pip 版本,果真是 8.1.2:
testuser@localhost ~ $ pip --version pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
根據討論,pip 之後應該是會改成顯示警告訊息,而不是直接掛掉…
但現在要暫時解掉這問題的話,有兩個方法~
1. 直接把造成問題的模組移掉
例如這次是 _ipap11helper 造成問題,就先把它移掉,再執行 pip freeze 就不會有問題了:
sudo pip uninstall _ipap11helper
2. 暫時使用舊版的 pip 8.1.1
這個問題是 pip 8.1.2 才出現的,所以我們可以裝回 8.1.1 版本來避開問題:
testuser@localhost ~ $ sudo pip install pip==8.1.1 Collecting pip==8.1.1 Downloading pip-8.1.1-py2.py3-none-any.whl (1.2MB) 100% |████████████████████████████████| 1.2MB 961kB/s Installing collected packages: pip Found existing installation: pip 8.1.2 Uninstalling pip-8.1.2: Successfully uninstalled pip-8.1.2 Successfully installed pip-8.1.1 You are using pip version 8.1.1, however version 8.1.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
看一下目前的 pip 的確降級成 8.1.1 了:
testuser@localhost ~ $ pip --version pip 8.1.1 from /usr/lib/python2.7/site-packages (python 2.7)
pip freeze 也能正常執行,注意第一個就是造成問題的 -ipap11helper 模組:
testuser@localhost ~ $ pip freeze -ipap11helper==0.1 backports.ssl-match-hostname==3.4.0.2 Beaker==1.5.4 blivet==0.61.15.37 Brlapi==0.6.0 cffi==0.8.6 chardet==2.2.1 colorama==0.3.7 configobj==4.7.2 configshell-fb==1.1.18
希望這問題可以盡快解決呀~
(本頁面已被瀏覽過 224 次)
One thought on “[CentOS] pip freeze 出現 parse error at "'-ipap11h'" 的問題”
thank you. downgrading to 8.1.1 helped me
版主回覆:(08/31/2016 02:48:39 AM)
You are welcome.
Hope there would be a new build for pip soon…