cairosvg installed but ImportError - python-3.x

I just installed cairosvg and it seems to have worked.
If i try to install again it says:
$ pip install cairosvg
Requirement already satisfied(...)
But if I try to import it in python3, it delivers an ImportError:
>>>import cairosvg
Traceback(most recent call last):
(...)
ImportError: No Module named 'cairosvg'
Any ideas whats going wrong here? By the way, im trying to convert .svg files to .png ones, if there is a simpler possibility, feel free to tell me!

install with pip3:
pip3 install cairosvg

Related

Error trying to import cv2(opencv-python) package

I am trying to access my webcam with cv2(opencv-python) package.
When I try to import it I get this error:
Traceback (most recent call last):
File "server.py", line 6, in <module>
import cv2
File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 5, in <module>
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Note: I am trying to import this package on putty, on Linode server - that might be useful information.
If anyone can explain to me what is happening and maybe solve the problem I will highly appreciate it!
Install opencv-python-headless instead of opencv-python. Server (headless) environments do not have GUI packages installed which is why you are seeing the error. opencv-python depends on Qt which in turn depends on X11 related libraries.
Other alternative is to run sudo apt-get install -y libgl1-mesa-dev which will provide the missing libGL.so.1 if you want to use opencv-python. The libgl1-mesa-dev package might be named differently depending on your GNU/Linux distribution.
Full installation guide for opencv-python can be found from the package documentation: https://github.com/skvark/opencv-python#installation-and-usage
this worked for me:
conda install -c fastai opencv-python-headless

ModuleNotFoundError: No module named 'requests'. But 'requests' already installed

Trying to import 'requests'.
Has it installed via pip3 install requests? But still, have this error.
C:\Users\Vikentiy>pip3 list
Package Version
---------- ----------
certifi 2018.11.29
chardet 3.0.4
Django 2.1.7
idna 2.8
pip 19.0.2
pytz 2018.9
requests 2.21.0
setuptools 40.6.2
simplejson 3.16.0
urllib3 1.24.1
virtualenv 16.4.0
C:\Users\Vikentiy>python --version
Python 3.7.2
Error Traceback:
C:\Users\Vikentiy\untitled2\venv\Scripts\python.exe C:/Users/Vikentiy/untitled2/requeststests.py
Traceback (most recent call last):
File "C:/Users/Vikentiy/untitled2/requeststests.py", line 1, in <module> import requests`
Try to uninstall requests and then again install it using pip
pip uninstall requests
and again install it
pip install requests
or if you didn't get what I am saying so please visit
https://scmquest.com/resolved-importerror-no-module-named-requests-usr-bin-python-no-module-named-pip-on-macos/
Another cause of this might be multiple Python versions installations. So if you type in your terminal:
pip3 install requests
The requests library will be automatically installed to your default python3, for example, Python3.6. However, let's say you have another Python version, for example, Python3.7, what you should do is:
pip3.7 install requests
This should solve this problem.
If you are running your code in the terminal, you should try:
python3.7 file_to_run.py
If you're using PyCharm as IDE, try closing and restarting PyCharm. Move the mouse cursor over the "requests" (with red curly line beneath it), until the red light bulb next to it show up. Select the first option in it, "Install package requests". PyCharm will take care of the installation from there.
I ran into the same issue and have tried all the solutions here on Stack Overflow.
If it is installed this will WORK:
c:\>python (or on Mac/Linux "$ python")
>>> import requests
>>> requests.get("http://127.0.0.1")
<Response [200]>
If you see this error when running your script/IDE:
Traceback (most recent call last): File "E:\test.py", line 1, in <module>
import requests
ImportError: No module named requests
Try:
python script.py
Answer is based on https://www.edureka.co/community/84584/python-requests-module-import-error-module-named-requests
Then the trick for me was not to start up a VirtualEnv, I actually found I was running the x64 version of python when I'd installed the requests package into the python 32 bit folder c:\program files (x86)\python37-32\lib\site-packages. This is a screenshot from the internet but it shows you how to change the interpreter you're using - in my case - I need to set it to Python 3.7.4(x86) 32 bit:
Run in command prompt
and write command pip install requests in scripts directory
cd \Python27\scripts
pip install requests
That's the exact solution which works for me, please follow this:
As like, first try to get the version of the requests module installed previously, this can be find by
pip install requests
Now, you will get the message:
Requirement already satisfied: requests in /opt/anaconda3/lib/python3.8/site-packages (2.24.0)
See, here the version of the requests module i.e., (2.24.0)
Now, the simple basic logic is this like you should install just the previous version of the requests (2.24.0). So, you should now install requests (2.20.0)
For this use command:
pip install requests==2.20.0
Now, I think you can test import requests and this will work fine.
Further, if any error occurs then please let me know in the comments.
Thanks,
HaPpY Coding 🤗
This issue is due to missing request module in python package .So you can use below command to install and recheck by restarting your IDE
pip install requests
If already installed better to upgrade
pip install --upgrade pip
If you are using venv (virtual environment), you may need to consider where it's path. for my case it was outside my project folder. So I had to first install request inside the main python's path then I recreate venv inside my project.
inside_your_project#python -m venv ./venv

python3 "ModuleNotFoundError: No module named 'OpenGL'"

I am running python3. I've installed OpenGL (pip install OpenGL PyOpenGL_accelerate). When I run my program (python3 opengltest1.py) I get this error:
Traceback (most recent call last):
File "opengltest1.py", line 4, in <module>
from OpenGL.GL import *
The solution was to install OpenGL with pip3 instead of pip, i.e.
pip3 install pyopengl
#eyllanesc Thanks for the help. In following up on your suggestion, I found the solution.
This worked for me! You must download every package with pip3. All things are separated because the syntax is different from Python 2 to Python 3.

How to install new module/package in python coding online environment?

I want to install third party package in python online coding environments. Could you please tell me how we can achieve this?
The below line needs to execute
from watson_developer_cloud import SpeechToTestV1 as STT
when I run the above line, I am getting the following error,
Error:
Traceback (most recent call last):
File "..\Playground\", line 1, in
\ufefffrom watson_developer_cloud import SpeechToTestV1 as STT
ImportError: No module named 'watson_developer_cloud'
Even tried the below command in CODE Playground but it throwing incorrect syntax.
pip install watson_developer_cloud
Thanks in advance,
I think you have to execute pip install --upgrade watson-developer-cloud
and not pip install watson_developer_cloud
https://github.com/watson-developer-cloud/python-sdk
You can install packages when using SoloLearn. You need to ask SoloLearn's administrators to install the package for you.
The python playground includes some of the most popular packages but it's very limited in terms of what you can do if the package you want to use is not there.

pip isn't working when importing something

To install pymongo for pypy3 2.1 Beta 1, I installed pip using the following commands:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
./pypy ez_setup.py --user
where pypy is the executable of pypy3 2.1 Beta 1. After that, pip and pip-3.2 will come to the current directory. But when running pip or pip-3.2, I get the error:
Traceback (most recent call first):
File "pip-3.2", line 5, in <module>
from pkg_resources import load_entry_point
zipimport.ZipImportError: pip==1.4.1
It seems that the problem comes from from pkg_resources import load_entry_point of the pip/pip-3.2. But this statement runs OK when I put it in pypy or python3 IDLE. What's the matter? How to solve this problem and proceed to install pymongo for pypy3 2.1 Beta 1? Thank you.
PS: I'm using Ubuntu. python3 is installed in the system. If u need any other information pertaining to solving the question, please comment.

Resources