0

conda ModuleNotFoundError in a virtual env but not in base

I am using Anaconda / Conda
Conda version 4.10.1
(base) Python 3.8.5

using the (base) environment, I create, build, and run my code without incident.

From the same path location and command consolte, I create and activate a conda virtual environment

I start to populate the env with the packages needed by trying to run the code and resolving each ModuleNotFoundError.
I started from Python (3.9.4)

When I get to yaml, it still fails to run on ModuleNotFoundError

python sgchecker.py
Traceback (most recent call last):
File "sgchecker.py", line 7, in
import yaml
ModuleNotFoundError: No module named 'yaml'

conda list

shows yaml (0.2.5) is installed

pip list

does not. This is not alarming as pip list does not always show the complete list of packages.
I install via conda as preferred method.

I tried:

  1. rolling back to yaml 0.1.17
  2. rolling back to Python 3.8.5
  3. installing yaml with pip

pip install yaml
ERROR: Could not find a version that satisfies the requirement yaml
ERROR: No matching distribution found for yaml

I tried (3) with yaml installed and removed via conda with same results

I suspect the results of (3) should lead to the solution, but so far, it has not.

related SO questions that did not help to solve the problem
ModuleNotFoundError only occurred in conda environment
ModuleNotFoundError when importing package that is installed in conda environment

J. Craig Williams
  • 380
  • 1
  • 2
  • 18

1 Answers1

4

Run this command inside conda environment:

conda install pyyaml
imxitiz
  • 3,920
  • 3
  • 9
  • 33
J. Craig Williams
  • 380
  • 1
  • 2
  • 18