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
Related
I believe I have successfully install TA-lib in Ubuntu VM (it is using ARM64) as when I type pip list, it shows in my python 3.8 packages together with all other modules. Unfortunatley, when I call import talib, an error as below exists
>>> import talib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ubuntu/.local/lib/python3.8/site-packages/talib/__init__.py", line 52, in <module>
from ._ta_lib import (
ImportError: libta_lib.so.0: cannot open shared object file: No such file or directory
https://imgur.com/1ZU4wZn.png
I also use the command export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH but the same error is shown.
The talib folders as per screenshot
https://imgur.com/ogIslEp.png
https://imgur.com/BIqXi37.png
It is a problem specific to ARM64 or AArch64 as I manage to install talib in X64. I successfully installed talib in X64 with the same Ubuntu version , the only difference is only it is in X64
Both ARM64 and X64 talib has the libta_lib.so.0 in ./ta-lib/src/.libs/libta_lib.so.0
It's normal, you shouldn't use pip to install python3 libraries, use pip3 instead, pip is for python2. Probably what happened is that you installed ta-lib for python2(that use pip) instead of python3(that use pip3).
Please, let us know if you still have problem after you executing the following command in a shell:
pip3 install ta-lib
The issue is specific to ARM/Aarch64 Virtual Machine in Ubuntu 20.04.
In your directory of Ubuntu, type
sudo ldconfig
To confirm if TA-lib able to import with error, reboot your VM.
This is the simplest way to fix the issue permanently without export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
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.
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.
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
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.