Solve the ModuleNotFoundError: No module named 'tensorflow' error reported in pycharm

 When writing a python program in pycharm, I encountered an error reporting ModuleNotFoundError: no module named XXX. Below is my workaround.

Table of contents

1. Mistakes

2. Reason Analysis

3. Solutions

Four, more error solutions


1. Mistakes

       When executing the python program, an error is reported, and the error message is ModuleNotFoundError: No module named 'tensorflow', where tensorflow is a third-party library I use.


2. Reason Analysis

      The error of ModuleNotFoundError is usually in your programming environment. For example, in the pycharm environment I used, the third-party library you used was not detected. Here are several possibilities:

       1) You have not installed the third-party library that reported the error, or you have not installed it successfully, for example, the name is wrong or the installation failed

        2) The installation is successful. You installed it in the CMD window, but your project in pycharm uses the venu virtual environment, which means that the installation location is wrong.

        3) It is also caused by the installation location. There are multiple versions of python on your computer, and the version of python specified in your computer environment variable is installed by default when installing on the CMD command line, and in your pycharm. Another version of python was used.


3. Solutions

     1. Open your pycharm, find the console Terminal at the bottom left:

    2. Click to enter the console Terminal, and enter the name of the pip show third-party library . For example, I encountered an error in tensorflow, so my command is:

pip show tensorflow

   3. It shows that this library is not detected here, indicating that I have not installed this library, or that the python environment used in my current project does not have this library, so I will install it directly here

pip install tensorflow

  After that it will be installed:

  After the installation is successful, I then use the pip show tensorflow command to detect the library.

  Then I went back to my program and ran my program without reporting an error.

    4. If you fail to install successfully using the pip command, you can also use another way to install:

        1) Click File in pycharm——"Setting—"Project Interpreter             

            2) Click the + icon on the right to add a third-party library:

           3) As shown in the figure, first search for the library to be installed, then select the library, and finally click the install library button in the lower left corner 

        

  Well, the above is the solution to the ModuleNotFoundError: No module named 'tensorflow' error reported in pycharm. No matter what causes you, it can basically be solved.


Four, more error solutions

        Please follow my column:

Guess you like

Origin blog.csdn.net/c1007857613/article/details/129284341