ModuleNotFoundError: No module named 'CairoSVG' - python

I have this code:
import CairoSVG
but I get this:
"C:\Program Files\Python36\python.exe" D:/PyCharmProjects/Exyz/Bla.py
Traceback (most recent call last):
File "D:/PyCharmProjects/xyz/Bla.py", line 1, in <module>
import CairoSVG
ModuleNotFoundError: No module named 'CairoSVG'
Process finished with exit code 1
I followed this and the package CairoSVG is definitely installed. I also did:
Go to File > Invalidate caches/restart and click Invalidate and Restart to apply changes and restart PyCharm.
What else could be wrong?

Using
import cairosvg
instead of
import CairoSVG
should fix your problem.
Source : http://cairosvg.org/

Related

Unable to import psutil in Python 3.7 (Import Error)

I am unable to import psutil when I activated python on my venv, its gives the following error message, which I cant resolve.
I tried to uninstall psutil and install psutil again but it still returns the same error.
>>> import psutil
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/__init__.py", line 157, in <module>
from . import _psosx as _psplatform
File "/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psosx.py", line 16, in <module>
from . import _psutil_osx as cext
ImportError: dlopen(/Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so, 2): Symbol not found: _kIOMasterPortDefault
Referenced from: /Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so
Expected in: flat namespace
in /Users/wenlin.kwek/Documents/fp_churn/venv/lib/python3.7/site-packages/psutil/_psutil_osx.cpython-37m-darwin.so
Will appreciate if anyone knows how to resolve this issue, thanks.
Does it raise the same error when you activate the venv, open the virtualenv python interpreter and import psutil?
Another cause I can think of is when you name your script psutil.py and within that script you try to import the psutil module.
(see the post of Yong Wang: airflow error:AttributeError: module 'airflow.utils.log' has no attribute 'file_processor_handler')

After installed asprise_ocr_sdk_python_api on mac, got "No module named 'ocr'"

I ran both
sudo pip install asprise_ocr_sdk_python_api
pip install asprise_ocr_sdk_python_api
Got message
"Requirement already satisfied: asprise_ocr_sdk_python_api in /Users/myid/miniconda3/envs/competition/lib/python3.5/site-packages"
But when I ran asprise_ocr to test:
Got the following error:
Traceback (most recent call last):
File "/Users/myuser/miniconda3/envs/competition/bin/asprise_ocr", line 7, in <module>
from asprise_ocr_api.ocr_app import run_ocr_app
File "/Users/myuser/miniconda3/envs/competition/lib/python3.5/site-packages/asprise_ocr_api/__init__.py", line 1, in <module>
from ocr import *
ImportError: No module named 'ocr'
The asprise_ocr_api module doesn't do submodule imports correctly in Python 3.
For example init.py contains from ocr import *. For a sub-module in Python 3 that should be from .ocr import *. Idem for from ocr_app import OcrApp, run_ocr_app. That should be from .ocr_app import OcrApp, run_ocr_app.
After making these changes in all files it imports correctly.
i've tried:
import ocr
same error:
ModuleNotFoundError: No module named 'ocr'
i am using python 3

sompy Module Import Error

I can't import the sompy module even though I installed it successfully, and it appears in the modules list of my python environment:
When I try to import the sompy module using the following statement:
import sompy
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sompy'
What's wrong?
Which interpreter/IDE are you using? If using PyCharm, the problem could be that PyCharm hasn't identified a root folder for your .py project.
I would try and recreate the root folder as a subfolder and right click > Make source directory.

Can't find submodule in package

I'm using Anaconda3 version 4.2.0 on ubuntu (in docker).
Anaconda is installed in /root/anaconda3 folder.
I installed theano_bpr package using pip install theano_bpr.
Now when i open python and try import theano_bpr, i get the following message:
>>> import theano_bpr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/anaconda3/lib/python3.5/site-packages/theano_bpr/__init__.py", line 17, in <module>
from bpr import BPR
ImportError: No module named 'bpr'
However, when i navigate to /root/anaconda3/lib/python3.5/site-packages/theano_bpr/ and run python there, i'm able to import theano_bpr.
In /root/anaconda3/lib/python3.5/site-packages/theano_bpr/ there are following files:
__init__.py, bpr.py (this one is causing problems), t.py, and utils.py.

How to install mathplotlib - python

I'm using sublime text 2 to run python 2.7. I have downloaded and installed mathplotlib. When I type the code:
import matplotlib.pyplot
I'm getting this error.
Traceback (most recent call last):
File "/Volumes/HP v190b/Python - Squash Coursework/squashFINAL.py", line 212, in <module>
import matplot.pyplot as plt
ImportError: No module named matplot.pyplot
Any ideas why? I'm using a Mac!
You may check the dependencies, sometimes you need to install some dependencies so that you can import certain module, take a look at this link http://matplotlib.org/users/installing.html

Categories

Resources