Troubleshooting Multiple Installations
I can’t import any modules even though I am sure I installed them.
My script works when I run it from IDE, but fails when i run it from Terminal/Command Prompt.
The Issue Explained
Python allows multiple versions to be installed in parallel on the same computer.
It even allows the same version to be installed in different location/directories on the computer.
How does it know which python to run when you open terminal and run “python scrypt.py”?
How does the IDE know which version of python you want to execute your code on?
How does the package manager know which python are you installing packages to?
This depends on many things, and having one setting point to one python and another setting point to another can cause issues.
Solving this issue requires going over all possible settings relevant to your environment and making sure they match what you expect.
If any setting does not match, changing it is required.
The list below should be done step by step for every environment that is relevant to your setup.
For example if you are running Visual Studio Code on Linux, you need to go over Linux, Visual Studio Code topics below.
Gathering Information and Fixing
- which python, python -V
- if using pip: which pip, pip -V
- assoc, ftype
- where python, python -V
- if using pip: where pip, pip -V
Using Visual Studio Code
- conda info
- conda list
I like shifting bytes around…