Anaconda Prompt

I have a script that works perfectly in the VSCode envrionment. But when I try to execute that script using the Anaconda Prompt, I get an error complaining that two moduels cannot be imported.

Is there something I can check to make this work?

Thanks…JohnC.

1 Like

dear John_Cole.

Thank you for your posting.
A similar phenomenon has also been reported on StackOverFlow, and we will provide a reference URL, so please check it.

Regards, you.
ktsh.tanaka.2020

Thank you for your reply. Unfortunatly, the suggested URL provided no solution.

Below is a snapshot of the Anaconda terminal interaction:
--------------------- Begin interaction --------------------------------------
(base) E:\Programming\Python\CodeLib>sandbox-imdb.py host
Traceback (most recent call last):
File “E:\Programming\Python\CodeLib\Sandbox-IMDB.py”, line 5, in
import psutil, platform
ModuleNotFoundError: No module named ‘psutil’

(base) E:\Programming\Python\CodeLib>conda install psutil
Collecting package metadata (current_repodata.json): done
Solving environment: done

All requested packages already installed.

Retrieving notices: …working… done

(base) E:\Programming\Python\CodeLib>sandbox-imdb.py host
Traceback (most recent call last):
File “E:\Programming\Python\CodeLib\Sandbox-IMDB.py”, line 5, in
import psutil, platform
ModuleNotFoundError: No module named ‘psutil’

(base) E:\Programming\Python\CodeLib>
------------------------------ End Interaction ----------------------------------

Entering python --version results in a response 3.9.12, the same version specified for VSCode.
As you can see, something is still wrong. Is there something else I can try?

JohnC

1 Like

dear John_Cole.

thank you for your reply.
Thank you for disclosing the error message.
The cause is easily found

It’s because the module “psutil 5.9.2” is not installed.

There are two ways to solve this problem.

  1. conda install -c conda-forge psutil

to install psutil on anaconda.

  1. pip install psutil

to install psutil in anaconda’s python.

Either of these methods will work.

Best regards
ktsh.tanaka.2020

I’ve tried both suggested commands in a number of scenarios with no success:

  • using Anaconda Prompt window as user with admin priv and as administrator
  • using VSCode Powershell terminal again as user with admin priv and as admninstrator

Belowe is the session in the Anaconda prompt as user with admin priv, and noticed this error:
EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
environment location: C:\ProgramData\Anaconda3

This occurred at my first attempt at installation:

------------------(Anaconda Prompt as user with administrator privleges.)----------------
(base) C:\Users\John>conda install -c conda-forge psutil
Collecting package metadata (current_repodata.json): done
Solving environment: done

Package Plan

environment location: C:\ProgramData\Anaconda3

added / updated specs:
- psutil

The following packages will be downloaded:

package                    |            build
---------------------------|-----------------
conda-4.14.0               |   py39hcbf5309_0         1.0 MB  conda-forge
python_abi-3.9             |           2_cp39           4 KB  conda-forge
-----------------------------------------------------------
                                       Total:         1.0 MB

The following NEW packages will be INSTALLED:

python_abi conda-forge/win-64::python_abi-3.9-2_cp39

The following packages will be SUPERSEDED by a higher-priority channel:

conda pkgs/main::conda-4.14.0-py39haa95532_0 → conda-forge::conda-4.14.0-py39hcbf5309_0

Proceed ([y]/n)? y

Downloading and Extracting Packages
python_abi-3.9 | 4 KB | ############################################################################ | 100%
conda-4.14.0 | 1.0 MB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: failed

EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
environment location: C:\ProgramData\Anaconda3

On subsequent installation attempts, the commands return a message saying the package is already installed. I can import psutil as always in VSCode, but not with the Anaconda prompt.

Should I re-install the entire Anaconda/VScode software and start again? This problem started after I downloaded and installed the latest version of Anaconda.

1 Like

dear John_Cole.

Thanks again for your detailed reply.

Based on the error situation you posted, it seems that it can be handled if it can be executed with Windows Professional Administrator privileges.

I don’t think re-installing the issue will fix the issue.

Therefore, we recommend that you consult with your Windows Professional administrator and install with administrator privileges.

Best regards
ktsh.tanaka.2020

Thanks for your help.

JohnC

1 Like

pip install git+https://github.com/openai/whisper.git