Today, a classmate reported online that the import Python package failed, with two pictures attached:
Figure 1. Error code
Figure 2. Error message
Combined with the above two pictures, we found that the student failed to import all, and initially suspected that there were no numpy and sklearn in the student’s local environment
After further communication, it was found that the student used the green installation package of Python 3. X (I am used to calling this language package with only the kernel part ‘naked package’) and successfully installed the above package through the PIP install command
Next, shoot and wipe. Because the version of the local environment is inconsistent with the error report, it is impossible to locate the specific reason. It is recommended to install the latest versions of anaconda and pycharm
At the same time, find the popular online treatment methods, and copy them as follows:
The main reason is that the pythpon version used in the IDE is different from the default installation version of the system, and the installed pymysql cannot be imported in the IDE.
1. Check the default installed Python version and installation directory in the system environment configuration, find the \ lib \ site packages under this directory, and check whether there is pymysql directory. If it exists, it indicates that you are installed in the current directory.
2. Check the python configured in your ide. Generally, it is not the version under the system environment configuration. You can switch to the version under the system configuration in the IDE. Or uninstall the version under the system configuration and reconfigure your Python version in the system environment variable. You mainly need to configure two (Python \ scripts); E: \ Python) the first is required to execute relevant commands, and the second is the basic information of Python.
No problem running in IDE after 3.
Summing up the above statements, it can be understood that the python versions of the editor and the interpreter are inconsistent, resulting in the failure of the editor in calling pymysql of the interpreter. The solution is to unify the versions between the two, and pay attention to modifying the environment variables.
1. The tools are as follows: if you use Anaconda’s own IDE, you can directly download and install anacond;
2. If it is used in combination with pycharm, you need to set the absolute path of python.exe in the interpreter.
- [Solved] yum Execute Error: -bash: /usr/bin/yum: /usr/bin/python3.7: bad interpreter: No such file or directory
- Error reporting of importing tensorflow package from pycharm
- Project interpreter not specified(eclipse+pydev)
- Pychar report Python package tools not found error
- centos ModuleNotFoundError: No module named ‘_sqlite3’
- Django: How to Solve Using Pymysql Error
- [Solved] yarn Install Module Error:check python checking for Python executable “python2” in the PATH
- Pychar can’t install the third-party library, the solution of error code non zero exit code (1)
- python mac install MySQLdb ModuleNotFoundError No module named ‘ConfigParser’
- The problem of error reporting when importing openpyxl from Python has finally been solved