dpholmes
dpholmes

Reputation: 111

Issue with Anaconda package manager - library installed, but not found in Spyder

I installed cairo using Anaconda Navigator (in case it's important, cairo is also installed in the other two environments: miniconda3 and spyder-env): cairo is installed

I launch Spyder from Anaconda Navigator, and try to import cairo, and get an error saying: ModuleNotFoundError: No module named 'cairo' no module named 'cairo'

Spyder seems to be using the correct python environment. If I run `conda list cairo', I get the following output: enter image description here

What am I doing wrong?

Upvotes: 0

Views: 1386

Answers (1)

mmustafaicer
mmustafaicer

Reputation: 434

I had problem similar to this with VaderSentiment analysis library. Jupyter notebook couldn't find it although it was installed. Either you can use a more stable Python version such as Python 3.7 for compatibility or you can use importlib.

conda install python=3.7

I solved it using importlib This does not answer your question "what am i doing wrong", but it solved the problem in my case. Just locate cairo.py in your Anaconda folder whatever the environment is. You can make necessary adjustments. I hope this helps if you have emergency to use that package.

import importlib.util
import sys
spec = importlib.util.spec_from_file_location("vaderSentiment", r"C:\Users\matt\Anaconda3\envs\sentiment\Lib\site-packages\vaderSentiment\vaderSentiment.py")
foo = importlib.util.module_from_spec(spec)
sys.modules["vaderSentiment"] = foo
spec.loader.exec_module(foo)

Upvotes: 1

Related Questions