1

Installed python package from the Anaconda Prompt in the virtual environment. import transformers works from the Anaconda Prompt. However, ModuleNotFoundError when in Jupyter Notebook even though kernel is set to the virtual environment where the package is installed.

It looks like the issue is similar to Jupyter notebook can't load installed package in conda environment, but I can't get it to work on Windows.

Here is an example.

Package is installed in the virtual environment.

Importing from the anaconda prompt works.

Importing from Jupyter Notebook causes the error.

ervsml
  • 21
  • 4

2 Answers2

0

Open the Jupyter notebook from command line. Activate your conda environment first.

  1. Open command line. Activate your conda environment. Type activate <your env name>

  2. Type jupyter notebook <path to your project>. To open in current directory jupyter notebook . .

fanbyprinciple
  • 554
  • 7
  • 14
0

The package was initially installed using conda install -c conda-forge transformers.

Instead, I installed the packaged using pip install transformers. Importing the package from Jupyter Notebook on the virtual environment's kernel worked fine afterwards.

When I did where conda from the virtual environment, conda install doesn't seem to be installing to the venv. Whereas where pip showed that the venv's pip is being used.

ervsml
  • 21
  • 4