源代码如下:
1 2 3 4 5 6 7 8 | C:\Users\86258>pip list Traceback (most recent call last): File "d:\python3.8.5\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "d:\python3.8.5\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\Python3.8.5\Scripts\pip.exe\__main__.py", line 4, in <module> ModuleNotFoundError: No module named 'pip' |
错误提示:
ModuleNotFoundError: No module named ‘pip’
莫慌,继续敲入:python -m ensurepip
1 2 3 4 5 6 | C:\Users\86258>python -m ensurepip Looking in links: c:\Users\86258\AppData\Local\Temp\tmpy2vkfsn9 Requirement already satisfied: setuptools in d:\python3.8.5\lib\site-packages (50.3.0) Processing c:\users\86258\appdata\local\temp\tmpy2vkfsn9\pip-20.1.1-py2.py3-none-any.whl Installing collected packages: pip Successfully installed pip-20.1.1 |
再继续敲入:python -m pip install --upgrade pip
1 2 3 4 5 6 7 8 9 | C:\Users\86258> python -m pip install --upgrade pip Collecting pip Using cached pip-20.2.4-py2.py3-none-any.whl (1.5 MB) Installing collected packages: pip Attempting uninstall: pip Found existing installation: pip 20.1.1 Uninstalling pip-20.1.1: Successfully uninstalled pip-20.1.1 Successfully installed pip-20.2.4 |
运行OK,此时pip list 可查看python中所有包和对应的版本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | C:\Users\86258>pip list Package Version --------------------- --------- -ip 20.2.3 argon2-cffi 20.1.0 asgiref 3.2.10 async-generator 1.10 attrs 20.2.0 Automat 20.2.0 backcall 0.2.0 bleach 3.2.1 certifi 2020.6.20 cffi 1.14.3 colorama 0.4.3 constantly 15.1.0 cryptography 3.1.1 cssselect 1.1.0 cycler 0.10.0 decorator 4.4.2 defusedxml 0.6.0 Django 2.2 django-redis 4.12.1 django-redis-sessions 0.6.1 entrypoints 0.3 hyperlink 20.0.1 idna 2.10 incremental 17.5.0 ipykernel 5.3.4 ipython 7.18.1 ipython-genutils 0.2.0 ipywidgets 7.5.1 itemadapter 0.1.1 itemloaders 1.0.3 jedi 0.17.2 Jinja2 2.11.2 jmespath 0.10.0 joblib 0.17.0 jsonschema 3.2.0 jupyter 1.0.0 jupyter-client 6.1.7 jupyter-console 6.2.0 jupyter-core 4.6.3 jupyterlab-pygments 0.1.2 kiwisolver 1.2.0 lxml 4.5.2 MarkupSafe 1.1.1 matplotlib 3.3.2 mistune 0.8.4 mysqlclient 1.4.6 nbclient 0.5.0 nbconvert 6.0.7 nbformat 5.0.7 nest-asyncio 1.4.1 notebook 6.1.4 numpy 1.19.1 opencv-python 4.4.0.42 packaging 20.4 pandas 1.1.3 pandocfilters 1.4.2 parsel 1.6.0 parso 0.7.1 pickleshare 0.7.5 Pillow 7.2.0 pip 20.2.4 prometheus-client 0.8.0 prompt-toolkit 3.0.7 Protego 0.1.16 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycparser 2.20 PyDispatcher 2.0.5 Pygments 2.6.1 PyHamcrest 2.0.2 PyMySQL 0.10.1 pyOpenSSL 19.1.0 pyparsing 2.4.7 PyPrind 2.11.2 pyrsistent 0.17.3 python-dateutil 2.8.1 pytz 2020.1 pywin32 228 pywinpty 0.5.7 pyzmq 19.0.2 qtconsole 4.7.7 QtPy 1.9.0 queuelib 1.5.0 redis 3.5.3 scikit-learn 0.23.2 scipy 1.5.2 Scrapy 2.3.0 scrapy-redis 0.6.8 Send2Trash 1.5.0 service-identity 18.1.0 setuptools 50.3.0 six 1.15.0 sklearn 0.0 some-package 0.1 sqlparse 0.3.1 terminado 0.9.1 testpath 0.4.4 threadpoolctl 2.1.0 tornado 6.0.4 traitlets 4.3.3 Twisted 20.3.0 w3lib 1.22.0 wcwidth 0.2.5 webencodings 0.5.1 wheel 0.35.1 widgetsnbextension 3.5.1 xlrd 1.2.0 zope.interface 5.1.2` |