I have written a python code in which I am using opencv-python. The code is perfectly running on my local machine. I am trying to make it live by uploading it on a server.
File "/var/www/xxxx/xxxxx/xxxxx/imgmask.py", line 2, in
import cv2 as cv
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
How can I resolve this problem? Please help!!
Note: I am using windows 10.
In the file you are importing cv2 copy the following code and paste and run it.
try:
import cv2
except Exception as e:
from pip._internal import main
main(["install", "opencv-python"])
finally:
pass
Good Luck, let me know if it works
If you use pipenv, you should write on terminal: pip install opencv-python
Related
I created some Python code in Jupyter Notebook and I would like to automate its exections using Windows Task Manager. I made .py file basing on Jupyter Notebook. Jupyter Notebook runs just fine - there is no problems with importing and using numpy. When I run .py script I get:
import numpy as np
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: Nie można odnaleźć określonego modułu.
# In english I believe it is: The specified module could not be found
I am working on Windows 10 and I am using Anaconda3. In anaconda-prompt I did pip list and checked it out: I have numpy installed. I am running my script by "C:\ProgramData\Anaconda3\python.exe" "C:\My\script.py".
I think it is some configuration problem, do anyone know solution or ever encountered similiar errors?
I am unable to run a python script in the command line, and this script works great in Jupyter Notebook and via Anaconda Prompt. This appears to be an issue importing the ssl module during initialization of another module I am importing (mygeotab).
I have googled the error and done as much as I can to diagnose the most common cause which appears to be PATH issues.
I have already diagnosed the PATH to a point, and have added the location of the /lib/ and python.exe to the environment variables. Also, during testing I began my script with the below to protect myself from path issues and printed the path before and after the 'append', which did not have an impact on the problem.
import sys
print(sys.path)
sys.path.append('C:\\Users\\xxxxxx\\Python Scripts')
sys.path.append('C:\\Anaconda3\\python37.zip')
sys.path.append('C:\\Anaconda3\\DLLs')
sys.path.append('C:\\Anaconda3\\lib')
sys.path.append('C:\\Anaconda3')
sys.path.append('C:\\Anaconda3\\lib\\site-packages')
sys.path.append('C:\\Anaconda3\\lib\\site-packages\\win32')
sys.path.append('C:\\Anaconda3\\lib\\site-packages\\win32\\lib')
sys.path.append('C:\\Anaconda3\\lib\\site-packages\\Pythonwin')
sys.path.append('C:\\Anaconda3\\lib\\site-packages\\IPython\\extensions')
sys.path.append('C:\\Users\\xxxxxx\\.ipython')
sys.path.append('C:\\Anaconda3\\Lib')
sys.path.append('C:\\Anaconda3\\Lib\\site-packages')
print(sys.path)
import mygeotab
import pandas as pd
import pyodbc as py
from mygeotab.ext import feed
import sqlalchemy
from time import sleep
However, when I attempt to run the script via the standard command line, I get the below error:
Traceback (most recent call last):
File "PYTHON_GEOTAB_TRIP_FEED.py", line 33, in <module>
import mygeotab
File "C:\Anaconda3\lib\site-packages\mygeotab\__init__.py", line 9, in <module>
from .api import Credentials
File "C:\Anaconda3\lib\site-packages\mygeotab\api.py", line 14, in <module>
import ssl
File "C:\Anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified module could not be found.
The mygeotab module and ssl.py are both in the locations designated in the Traceback. '_ssl' is the only reference I can not seem to diagnose. Again, this works fine in both Notebook and Anaconda Prompt.
Any ideas?
Windows Server 2008 R2
Anaconda 2019.07 x64
Python 3.7.3 x64
This was solved for me by installing a separate instance of Python 3.7, moving the PATH references and other pointers. I installed pip, mygeotab, and the other packages into the native Python 3.7 instance. It just appears you can't use the one baked into anaconda the way I thought. Thanks for the help everyone.
I am trying to send data to the Azure Blob Storage and my first step was to just check the connection by using the sample code I found on the tutorial website:
from azure.storage.blob import BlockBlobService
blob_service = BlockBlobService(account_name, account_key)
blob_service.create_container(
'mycontainername',
public_access=PublicAccess.Blob
)
blob_service.create_blob_from_bytes(
'mycontainername',
'myblobname',
b'<center><h1>Hello World!</h1></center>',
content_settings=ContentSettings('text/html')
)
print(blob_service.make_blob_url('mycontainername', 'myblobname'))
Of course entered the account name and the account key. But I get this error, which I also get when using my own python script so this is a big problem for me:
Traceback (most recent call last):
File "azuretest.py", line 1, in <module>
from azure.storage.blob import BlockBlobService
ImportError: No module named 'azure'
I am a beginner in this topic and I am very lost. Can anyone tell me what to do? Thanks
Installing just the azure-storage library should be sufficient in stead of installing the entire SDK.
pip install azure-storage
Edit
I see you have already done this. The package might not be in your python path. You could try adding
import sys
sys.path.append('/usr/local/lib/python3.6/dist-packages')
at the top of your script (but I am not 100% sure that it will be there on your syste, it is on ubuntu)
or append it to your PYTHONPATH environment variable.
I run the setup from this website to get my arduino to use AdaFruit LEDs.
And also run:
sudo pip3 install adafruit-circuitpython-neopixel
I then made this python code:
import board
import neopixel
pixels = neopixel.NeoPixel(board.D18, 12, brightness=0.2)
pixels[0] = (255, 0, 0)
And then executed it with python filename.py
And got the error:
ImportError: No module named 'board'
I then thought I maybe need to use python3 (Because it every where says too)
So I typed:
python3 light-test.py
This time got some more output, but in the end again an ImportError:
File "light-test.py", line 2, in <module>
import neopixel
File "/usr/local/lib/python3.5/dist-packages/neopixel.py", line 34, in
<module>
from neopixel_write import neopixel_write
File "/home/pi/.local/lib/python3.5/site-packages/neopixel_write.py", line
15, in <module>
from adafruit_blinka.microcontroller.raspi_23 import neopixel as _neopixel
File "/home/pi/.local/lib/python3.5/site-
packages/adafruit_blinka/microcontroller/raspi_23/neopixel.py", line 3, in
<module>
import _rpi_ws281x as ws
ImportError: No module named '_rpi_ws281x'
So I don't know know what I am doing wrong.
You're right to use Python3 instead of Python2.
One solution suggested here is to build the rpi_ws281x code from source.
Before that, however, you could try running as a super user/ administrator as suggested here.
If you're missing the 'board' module, that gets installed with the following pip3 command:
sudo pip3 install adafruit-blinka
I found that there was a board module already installed on my system (the wrong one). I deleted the board module and reinstalled adafruit-blinka to fix this.
I am working with numpy and Pillow (replacement for PIL in 3.4), but have been having problems with the importing of Pillow. I found a similar post here:
ImportError: Cannot import name X
However, this post was using his own created libraries and the problem was that his modules imported each other, creating circular dependent imports.
My code however does not use my own module, here is the code:
import PIL
from PIL import ImageGrab
import numpy
img = ImageGrab.grab()
imgLoad = img.load()
size = img.size()
And this then returns the error:
Traceback (most recent call last):
File "E:/Family Documents/Matthew's Documents/Python/PIL.py", line 1, in <module>
import PIL
File "E:/Family Documents/Matthew's Documents/Python\PIL.py", line 2, in <module>
from PIL import ImageGrab
ImportError: cannot import name 'ImageGrab'
One other interesting thing about this is that when I first installed Pillow (PIL), I tried it in the shell and the "from PIL import ImageGrab" worked.
Also, if I restart the shell (close it and re-open it) the commands, being manually typed in, work as well. This suggests to me that something is bugging out with python, since retyping "import PIL" throws the same error message "cannot import name 'ImageGrab'".
Thanks for any help
Ha, this already bit me multiple times.
Your traceback shows the file name:
E:/Family Documents/Matthew's Documents/Python/PIL.py
Your PIL.py is found first, so you're trying to import names from the module that's just executing, not from the actual library you have installed.