Successfully resolved the import paddle error

Project scenario:

Recently, it is necessary to build a paddle environment on the CPU, but due to irresistible factors, there was a small episode, so this article


Problem Description

There are already paddles in the environment, as follows:
insert image description here

But when importing, the following error occurred:
insert image description here


Cause Analysis:

At first, I thought that the installation method of paddle was wrong (direct pip installation), so I tried the following:

  • Conda installation, the command is as follows:
python -m pip install paddlepaddle==2.2.2 -i https://mirror.baidu.com/pypi/simple
  • Offline installation, download the corresponding whl file, and then install it, the URL is as follows:
    whl

However, the error is still the same. Later, I found out on the Internet that the linux version may be wrong, so I tried a solution.


solution:

  • Docker installation (recommended), the command is as follows, here only CPU is used as an example:
docker pull registry.baidubce.com/paddlepaddle/paddle:2.3.2

Among them, 2.3.2 can be directly changed to the version number you need. In line with the principle of "the second best", the version I choose is version 2.2, and then enter the mirror image (the specific command will not be expanded here, find it online mother), the result is as follows:
insert image description here
Then, let’s see if there is an error when importing the paddle:
insert image description here
as shown in the figure, there is no error and it can be used normally

  • Change your linux version
    and check your linux version. The version of my machine is Ubuntu22.04. The previous machine was Ubuntu20.04 and this problem did not occur. It may be that paddle is compatible with the linux version. bug. But I find it troublesome to reinstall the system, so I choose docker installation directly, and I also recommend that you use docker installation

The above is the entire content of this article. If you have any questions, please post them in the comment area. In the end, I vented my dissatisfaction, and asked Baidu's staff how to solve this bug in private chat, but they didn't reply to me. When I was asked to write a questionnaire, I always answered every question. -_-

Guess you like

Origin blog.csdn.net/qq_55068938/article/details/128021031