Conda env nesting causes bugs

**Cause:** I wanted to add new features. In order to prevent the configured conda environment from being destroyed, I copied the conda env and encountered several problems.
Problems:
1. Torchvision and several other packages indicate that they do not exist, but in fact they all exist in the original env and are used normally.
2. Opencv reports an error. The main reason is the patent restriction issue of sift feature point matching. The original env is 3.4.2.16 and can be used normally.
Final conclusion:
There is a nested relationship between conda's envs, and the virtual environment can be entered again in the virtual environment, causing a series of mysterious bugs.
If your virtual image is nested, use conda deactivate to return to the base environment and then enter the virtual image to solve the problem.

conda deactivate 

Halfway through, I also solved a little problem before I found that I needed to exit the environment, but I felt that the operation was probably an accident.
An accidental solution may not be the correct solution:
Regarding 1., it is probably solved by accident. The method is to reinstall the package that reported the error and was missing. Among them, I reinstalled torchvision by entering the complete instructions for installing pytorch. What is installed here is torch 1.7.0.

pip install torch==1.7.0 torchvision==0.8.0 torchaudio==0.7.0

The result was a reminder that I had installed these things, and torchvision was inexplicably available.
No errors will be reported after other packages are installed normally.
For 2., after the other packages are normal, opencv starts to prompt sift's patent issue module 'cv2.cv2' has no attribute 'xfeatures2d' . At this time, the conda list shows that my python version is 3.6.9 and the opencv version is 3.4.2.16. , the original env runs fine and the copied new env looks fine too, but the error persists.
Therefore, I tried to repeat the same trick and reinstalled 3.4.2.16 "rush". The result was ERROR: No matching distribution found for opencv-python==3.4.2.16 .
According to the search, it should be that the python version is wrong. 3.4.2.16 is no longer supported after python3.8 (reference from: https://www.pythonheidong.com/blog/article/889021/8406cf9cb74af2dafac0/ ), so the python version needs to be corrected. .
But my version is already lower than 3.8, 3.6.9>3.8?
Out of luck, I reinstalled python3.6.9, and the prompt is already 3.6.9, but the ERROR still exists. Use python --version to check the version and find that it is python3.7.3. 3.7.3? Where does it come from? It’s so strange, and 3.7.3>3.8?
With the attitude of giving it a try, I started searching for " python --version" and the version displayed by conda list are different.” solution, I finally found a real solution!
Thanks to G_inkk for providing a fresh solution two months ago! (Reference from: https://blog.csdn.net/G_inkk/article/details/120865842 )
Completed Flower! Cry.

Supongo que te gusta

Origin blog.csdn.net/a272881819/article/details/122132196
Recomendado
Clasificación