Tag Archives: import

Golang reported an error in importing its own package

Reason: after using the GIT clone project, the project root path is a lowercase English name, such as cmdbapi, but when the import in the project imports its own related packages, an error is reported in red

 

 

Solution: rewrite the project name to the name of the import package, namely cmdbapi. Of course, you can also rewrite the import package to lowercase

PIP Python package succeeds, but an error is reported when importing

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.