foreword
In the past, I only knew that Jupyter notebook did not pay attention to Google and has the same product. Recently, I have done a series of operations on machine learning. Let me talk about installing third-party modules. Use xxx as the !pip install XXX
package name to install it.
Encountered pit
The first is the Python version problem. You may encounter the problem of importing an error after installation, telling you that the package does not exist, but you can find that !pip list
you have already installed the package by checking the package installation list, or you can use it directly !pip show package_name
. Check the name, and found that the packages are all installed. Later,
I thought that my Python file was not in the same folder as the package, and I used the import sys module to switch the directory and found that there was still an error. There is no corresponding package.
Solution
First of all, make it clear that google colab !pip install XXX
is installed globally, that is to say, it can be used globally. The first part is to judge whether your Python version is compatible with this package. If it is not compatible, you need to use it to !apt-get install python3.9
upgrade the version. If this does not solve your import package If there is a wrong problem, you need to restart the operating environment, just like a computer with a win system that needs to be restarted to fully use it after installing a certain software.
You can solve this problem by finding the restart code execution program in the code execution tool.