ModuleNotFoundError in a Python virtual environment
Experiencing this error when you try to execute commands inside your Python virtual environment?
ModuleNotFoundError: No module named '<name of module>'
I encountered it a while ago.
The reason might be because you transfered your virtual environment folder to another location (or you copied it from another computer, like in my case).
This is how to fix it:
/Scripts/activatefile inside your virtual environment folder.
- Go to the line that has this (in my case, it is on line
VIRTUAL_ENV="$(if [ "$OSTYPE" "==" "cygwin" ]; then cygpath -u 'Z:\<your NEW folder>'; else echo '/Z/<your NEW folder>'; fi;)"
Change the path to the new location of your virtual environment.
Change it from
Z:\<your OLD folder>and
/Z/<your OLD folder>
Z:\<your NEW folder>and
/Z/<your NEW folder>
- If you are using the Command Prompt of Windows, you also have to change the path in the file
#2in my case)