Learn about the problems that Python encounters when installing packages in Pycharm

Source: Internet
Author: User

problem: Module ' pip ' has no attribute the ' main '

Before learning the Python crawler video by chance to see a lecturer directly in the Pycharm to install the package, for small white and only know that the PIP install command under CMD installation is very novel to me.

Also, the benefits of installing packages directly in Pycharm have two:

01, when writing a Python program under Pycharm, it is convenient to install the required packages under Pycharm.

02, to avoid the installation of multiple Python environment in the computer, so that the installation of CMD under the package Ken spoof installation is not now said to use the environment.

Just start my operation: File>>setting>>python interpreter>> Click "+" in the upper right corner to install the new package

Then the following interface appears

Without checking the istall ... option to collect the required packages in the Lasso box and then proceed to the install package.

Then the problem came, the system made the following error:

1 Executed Command:2Pip Install--index-url http://mirrors.aliyun.com/pypi/simple/Pydot3 4 Error occurred:5Attributeerror:module'Pip'has no attribute'Main'6 7 Traceback (most recent):8File""9File""Ten         returnPip.main (['Install'+pkgs]) OneAttributeerror:module'Pip'has no attribute'Main'
View Code

On the Internet through a variety of collection and I found the solution and the wrong amount of reason, originally because I updated the PIP this Python package (pip8.0-->pip18.0)

How to Solve

Under Install Pycharm folder to find the helpers, and then found in the file with a bad name packing_tools.py, and then open

Find the following code:

1 defDo_install (pkgs):2     Try:3         ImportPip4     exceptImorterror:5 Error_no_pip ()6     returnPip.main (['Install']+pkgs)7 8 defDo_uninstall (pkgs):9     Try:Ten         ImportPip One     exceptImorterror: A Error_no_pip () -     returnPip.main (['Uninstall']+pkgs)
View Code

Modify it to the following code, and then save it:

1 defDo_install (pkgs):2     Try:   3         Try:4              fromPip._internalImportMain5         exceptException:6                  fromPipImportMain7     exceptImporterror:8 Error_no_pip ()9     returnMain (['Install']+pkgs)Ten  One defDo_install (pkgs): A     Try:    -         Try: -              fromPip._internalImportMain the         exceptException: -                  fromPipImportMain -     exceptImporterror: - Error_no_pip () +     returnMain (['Uninstall']+pkgs)
View Code

Learn about the problems that Python encounters when installing packages in Pycharm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.