After solving the pip installation package in the Linux server, you can use pip show packageName but cannot import

1 question

I have root privileges and user test privileges in the server.
The environment created by Anaconda includes base (python 3.10) and py37 (python 3.7)
. After passing the command pip install celery package, you can view the version and installation path of the package through pip show celery. After entering the python environment on the terminal, after importing celery, it prompts that there is no such package name.

2 solutions

(1) The reason for the error in method 1
: I often use the root authority to install the package, but use the package under the test user. The permissions are inconsistent and cannot be used.

Solution: After entering the root authority, delete the package, then return to the user authority, and reinstall the package

Enter root authority

su
pip uninstall celery

Re-enter user rights

su test
pip install celery

(2) The reason for the error in method 2
: In the terminal, sometimes enter python to enter the python environment. The version does not correspond to the python version in conda.
For example, if you enter the following command in the terminal, you should enter the environment of python3.7.

conda activate py37
python

But sometimes it shows that it is entering the pyhon3.10 environment.

Solution: At this time, close the terminal and enter the command again to enter correctly.

Guess you like

Origin blog.csdn.net/weixin_43935696/article/details/130747881