When I do pip --version it show the error as ImportError: No module named pyparsing

余生颓废 提交于 2020-01-01 09:04:54

问题


I tried installing/uninstalling pyparsing as well and it does not work. I am stuck with this and I have to install additional libraries as well.

Here is the error message:

Traceback (most recent call last): 
File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
File "/home/rachana/.local/lib/python2.7/site-packages/pkg_resour‌​ces/__init__.py", line 72, in <module>
    import packaging.requirements
File "/home/rachana/.local/lib/python2.7/site-packages/packaging/‌​requirements.py", line 9, in <module>
    from pyparsing import stringStart, stringEnd, originalTextFor, ParseException
ImportError: No module named pyparsing

How can I fix this?


回答1:


I'm had the same problem and resolved it. Here is you can see that pip not working properly (without any additional parameters).

root@notebook:/home/ci# pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 72, in <module>
    import packaging.requirements
  File "/usr/local/lib/python2.7/dist-packages/packaging/requirements.py", line 9, in <module>
    from pyparsing import stringStart, stringEnd, originalTextFor, ParseException

Okay, so first that we may do is installing broken dependency:

wget https://pypi.python.org/packages/3c/ec/a94f8cf7274ea60b5413df054f82a8980523efd712ec55a59e7c3357cf7c/pyparsing-2.2.0.tar.gz
gunzip pyparsing-2.2.0.tar.gz
tar -xvf pyparsing-2.2.0.tar
cd pyparsing-2.2.0 && python setup.py install

After it mising dependency will be installed from sources.

Trying to using pip one more time:

root@rundeck.euovh01.un.private:/tmp/pyparsing-2.2.0# pip
Traceback (most recent call last):
  File "/usr/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 74, in <module>
    import appdirs
ImportError: No module named appdirs

This is the next problem. And you can fix it more quickly:

root@notebook:/home/ci# python -m pip install appdirs
Downloading/unpacking appdirs
  Downloading appdirs-1.4.3-py2.py3-none-any.whl
Installing collected packages: appdirs
Successfully installed appdirs
Cleaning up...

After that my pip was successfully repaired. Kind regards.




回答2:


Similar to @Oleg Mykolaichenko answer, but using pip:

[sudo] pip install pyparsing

[sudo] pip install appdirs



回答3:


ah! I was stuck with for an hour and found this out

pip3 install pyparsing


来源:https://stackoverflow.com/questions/42181056/when-i-do-pip-version-it-show-the-error-as-importerror-no-module-named-pypars

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!