Dev Note: Cheats Lists on Virtual Environment Building with `conda`
Dev Note: Cheats Lists on Virtual Environment Building with conda
Problems:
If you built virtual environment with conda and pyenv, sometimes configuration files might conflict, thus pip install packages in global environment instead of local one. I just encountered this problem which motivates me to record how I fixed it.
Error
- Status: testing cross-device function of application
- Git clone from my private repo and created env with
conda create -n myenv python=3.11 - However, after run
pip install -r requirements.txt, Python scripts could not be executed due to ModuleNotFound Error
Solution
I fixed the error by following steps:
- Check PATHs including
pyenv - Change the version of python
Check PATH of conda, python, pip
Almost all ModuleNotFound Errors are resulted from wrong install path, thus I checked PATHs
1 | which conda |
-> PATHs of conda and python were correct.
However, when I checked PATH of pip, it showed:
1 | which pip |
-> pip PATH is anchored to the global but not local.
Potential problem
Then I typed following steps (ordinary process):
- Unless changed python version from 3.11 to 3.10
1 | remove previous conda virtual environment |
-> This error probably due to python 3.11
Conclusion
This kind of ModuleNotFound Error due to python 3.11, configuration files might conflict. Thus, it is stable to install python 3.10 to keep PATHs of conda, python and pip in correspond dir.
Keywords:
#dev_note #conda #python
