I am trying to install python-tesseract 0.9-0.5 from a deb file on Ubuntu 15.04, but it gives several errors.
This is what I do:
1- I open the path of the file on terminal and write
sudo dpkg -i python-tesseract_0.9-0.5ubuntu2_i386.deb
2- After this, the console shows several errors:
Selecting previously unselected package python-tesseract.
(Reading database ... 349994 files and directories currently installed.)
Preparing to unpack python-tesseract_0.9-0.5ubuntu2_i386.deb ...
Unpacking python-tesseract (0.9-0.5ubuntu2) ...
dpkg: dependency problems prevent configuration of python-tesseract:
python-tesseract depends on python (<< 2.8).
python-tesseract depends on python (>= 2.7~).
python-tesseract depends on liblept4.
python-tesseract depends on libopencv-core2.4; however:
Package libopencv-core2.4:i386 is not installed.
python-tesseract depends on libtesseract3; however:
dpkg: error processing package python-tesseract (--install):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python-tesseract
3- Just for checking, I open the installation file and extracted the tesseract.py class, and used alone in python.
I opened it this way:
python tesseract.py
, but I got this:
Traceback (most recent call last):
File "tesseract.py", line 28, in <module>
_tesseract = swig_import_helper()
File "tesseract.py", line 20, in swig_import_helper
import _tesseract
ImportError: No module named _tesseract
The thing is that I want to use tesseract functions on python for an optical character recognition application, and I have understood that the best wrapper for this is python-tesseract (is not the same that pytesseract, I think).
My question is: How can I to install python-tesseract on Ubuntu 15.04? Thanks a lot
sudo apt-get install tesseract-ocr
**After Entering this command in terminal it will install tesseract **
Update and install tesseract-ocr
sudo apt-get update && sudo apt-get install tesseract-ocr
Install pytesseract for python
pip3 install pytesseract
Usage
import pytesseract
from PIL import Image
img= "path/img.jpg"
text = pytesseract.image_to_string(Image.open(img))
print(text)
When I was trying to get python to use Tesseract, I found this tutorial which was pretty useful.
But I then found out that this was way too simple for my needs, so I will need to find a another solution.
I hope this is going to help you man!
It works installing gdebi-core first, and afterwards installing the .deb package with it, so that gdebi install dependencies for me. I used Ubuntu 14.04.
sudo apt-get install gdebi-core
sudo gdebi python-tesseract_0.9-0.5ubuntu2_i386.deb
Use this link for installation
once you do that,
here is the code
from PIL import Image
img="pathToYourImage/img.jpeg"
text = pytesseract.image_to_string(Image.open(img))
print(text)
Related
from here: https://stackoverflow.com/questaions/34507045/how-to-install-man-pages-for-c11 there is mentioned,
cppman is no longer supported under Ubuntu/apt
and therefor no libstdc++6-<version>-doc could be install via apt anymore.
and the only way to install the man page is via pip3. So I have tried to install
sudo apt-get install python-pip and sudo apt-get install python3-pip. Now, having python3, I can install it via pip3:
pip3 install cppman, everything seems correct, before I tried to cache the man pages: cppman -c, which giver error:
Traceback (most recent call last):
File "/usr/local/bin/cppman", line 40, in <module>
from cppman.main import Cppman
File "/usr/local/lib/python2.7/dist-packages/cppman/main.py", line 26, in <module>
import html
ImportError: No module named html
As could be seen, it uses Python2.7 instead of Python3, that is strange.
From github, I have found similar problem here: https://github.com/aitjcize/cppman/issues/80, where they suggest to do
pip uninstall mancpp
pip3 install mancpp
Which I did, but when installing mancpp again from pip3, then another server error:
Collecting mancpp
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/mancpp/
So what now? If you read till here, than you can see there are many errors, but cannot find solution anywhere in stack sites. I only want to have cpp manuals for searching for functions and classes (like std) and mainly for glibc++. As I could do simply with c functions. Why is it so hard? Anyway, how to install the mancpp via pip3?
uname -a:
Linux 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux
The script uses #!/usr/bin/env python shebang and on your system python is most probably 2.7. Just edit the script:
sudo vim /usr/local/bin/cppman
Append 3 at the end: #!/usr/bin/env python3 and try again.
I'm working with reading sensor values through a Raspberry Pi 3 using Python, and I'm currently using this library: https://github.com/szazo/DHT11_Python. I am fairly new to the language and since there are no instructions in the README on how to install this library, I was wondering if anyone knows how to do it manually? I would just like to get rid of this error:
Traceback (most recent call last):
File "sensorRead.py", line 4, in <module>
import dht11
ImportError: No module name 'dht11'
So far, I ran these commands:
sudo git clone https://github.com/szazo/DHT11_Python.git
cd DHT11_Python
sudo apt-get update
sudo apt-get install build-essential python-dev python-openssl
Then, I moved the library from /home/pi to /usr/lib but I'm still getting the same error. I must be missing something.
If anyone knows how to properly install this library, then please help! Thank you!
You just need to have your sensorRead.py file in the same folder as dht11.py
Running flexget Python script in Ubuntu, I get an error:
$ flexget series forget "Orange is the new black" s03e01
Traceback (most recent call last):
File "/usr/local/bin/flexget", line 7, in <module>
from flexget import main
File "/usr/local/lib/python2.7/dist-packages/flexget/__init__.py", line 11, in <module>
from flexget.manager import Manager
File "/usr/local/lib/python2.7/dist-packages/flexget/manager.py", line 21, in <module>
from sqlalchemy.ext.declarative import declarative_base
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/__init__.py", line 8, in <module>
from .api import declarative_base, synonym_for, comparable_using, \
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/api.py", line 11, in <module>
from ...orm import synonym as _orm_synonym, \
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/__init__.py", line 17, in <module>
from .mapper import (
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 27, in <module>
from . import properties
ValueError: bad marshal data (unknown type code)
If you get that error, the compiled version of the Python module (the .pyc file) is corrupt probably. Gentoo Linux provides python-updater, but in Debian the easier way to fix: just delete the .pyc file. If you don't know the pyc, just delete all of them (as root):
find /usr -name '*.pyc' -delete
There also appears to have been some sort of regression in setuptools with use with python 3.7. See for an example - https://github.com/pypa/setuptools/issues/1257
Forcing reinstallation of setuptools fixed this issue for me.
sudo pip3 install --upgrade --force-reinstall setuptools
Just delete
/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/properties.pyc
it is corrupt as the text indicates. You'll probably have to do so as root.
After that start (again as root) run python (2.7):
/usr/bin/python -c "import sqlalchemy.orm.properties"
to recreate this .pyc file.
If you don't recreate the .pyc file, your program starts slower than necessary as the .py file takes longer to load than the .pyc (and a normal user cannot write the .pyc file).
This can happen if you have Python 2.7 .pyc files and you try to load them using Python 3.5. In my case this was a third-party tarball that erroneously included pre-compiled Python 2.7 .pyc files along with the source code.
I get this error in Ubuntu 18.04 Raspberry Pi 3 when I trying update my system typing sudo apt-get update and solve this error just typing:
sudo find /usr -name '*.pyc' -delete
This is remove all .pyc file in my system. Now I typing again sudo apt-get update && sudo apt-get upgrade and I get my update without thie error marshal-data
I resolved a similar error by un-installing and re-installing the Python application I was using, and all dependencies, using the system package manager.
In my case I was using awscli on Debian 9 and the error was "ValueError: bad marshal data (set size out of range)".
I ran as root:
apt-get purge awscli
apt-get autoremove
apt-get install awscli
And then the error was fixed.
I could imagine cases where the broken package might not get removed (for example because it was marked as manually installed, or was a dependency of another application still installed), in those cases this action may not resolve the error. However I thought I should try this way before manually deleting .pyc files the system installed, and I got lucky.
I also got this problem in Windows environment(win 10).
I fixed it by going to the Settings and repairing Python 3.7 with its installer.
Everything works fine since then.
As far as I could recall, I had kept a dash server running when my computer went to hibernation.
Maybe the damage was done in the hibernating process somehow.
I solved this problem by the following procedure :
In the error code message, you can see
from sqlalchemy.ext.declarative import declarative_base cause this error.
So just pip uninstall sqlalchemy and pip install sqlalchemy, problem solved.
It may be because of the damage of the library. Try re-install the package.
I had the same error in a conda environment which traced back to importing the matplotlib package.
simply pip uninstall matplotlib and then pip install matplotlib solved the problem.
Trying to get opencv for python working on Mac OSX - Mavericks but keep getting an image not found for libjpeg.8.dylib when doing import cv from python
(Recently updated from Mountain Lion)
This is what I did:
1.brew tap homebrew/science
2.brew install opencv
3.python
4.import cv
-got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py", line 1, in <module>
from cv2.cv import *
ImportError: dlopen(/usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so, 2): Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /usr/local/Cellar/opencv/2.4.9/lib/libopencv_highgui.2.4.dylib
Reason: image not found
I looked for libjpeg.8.dylib and found it in /usr/local/Cellar/jpeg/8d/lib/ which, apparently, is not where libopencv_highgui.2.4.dylib is looking.
I'm a bit new to Mac OS and homebrew. Could anyone explain how to resolve this error and get opencv running? I have the python that comes preinstalled with Mac and them python installed by homebrew.
Thank you.
The quick and dirty solution for this is to make a symlink inside of the /usr/local/lib folder pointing to the actual location of libjpeg.8.dylib, like this:
$ sudo ln -s /usr/local/Cellar/jpeg/8d/lib/libjpeg.8.dylib /usr/local/lib/libjpeg.8.dylib
The problem is opencv and python expect libjpeg.8.dylib to be in /usr/local/lib/ but homebrew installs it in /usr/local/Cellar/, hence annoying error.
I used brew a for installing OpenCV on my mac, and ran into this same problem, but it was with an Xcode C++ console application.
However an alternative method to solve the problem is to copy cp the file to the library location.
cp /usr/local/Cellar/jpeg/8d/lib/libjpeg.8.dylib /usr/local/lib/libjpeg.8.dylib
Or the latter, which I don't suggest, just stating another method is to use move mv the entire file location into your /usr/local/lib/ directory.
mv /usr/local/Cellar/jpeg/8d/lib/libjpeg.8.dylib /usr/local/lib/
Just had a similar problem to this (in python import opencv was working for me one day, then the next it threw the same error you are reporting) and this solution just worked for me:
Upgrade your homebrew opencv eg.:
brew upgrade opencv (or in my case brew upgrade opencv3)
Hope this helps
I had a similar problem with the Pillow library on macOS. The solution proposed here to install it from source worked for me. I had to install it to /usr/local/ for Pillow to find it. You'll need command-line tools, which is the purpose of the first line:
xcode-select --install
curl -O -J -L http://www.ijg.org/files/jpegsrc.v8.tar.gz
tar xvfz jpeg*tar.gz # Unzip and untar what you downloaded
cd jpeg-8 # Change directory to wherever it unpacked to
./configure --prefix="/usr/local" # Configure with the necessary prefix
make
sudo make install
I installed a new module and it appears as if one of its dependencies was not already installed. The module is called Xlib.display.
Here is the error message I received:
from Xlib.display import Display
ImportError: No module named Xlib.display
Where can I find this module that I am apparently lacking? Google yielded no leads.
"Edit: I already have that sourceforge module downloaded but I still get the same results.
Please try.
This shall install Xlib
sudo apt-get install python-xlib
Then you can check
>>from Xlib.display import Display
To install PyMouse if you want to control and capture mouse events please use:
sudo easy_install https://github.com/pepijndevos/PyMouse/zipball/master
Below worked for me!
pip install python3_xlib
I have also used pyuserinput for automation which requires this.
I was having the same problem, but the solutions above didn't work for me. Since I had installed python through the anaconda package, when I used:
sudo apt-get install python-xlib
Xlib was still undetectable by python2. The solution in my case was to use:
anaconda search -t conda python-xlib
Then find the package from the anaconda api, mine was erik/python-xlib. Install it using:
conda install --channel https://conda.anaconda.org/erik python-xlib
Then it worked.
On Debian systems install python-xlib.
On other systems there's a high probability that the package carries the same name.
I don't think the Xlib library works in Python 3.
Source:
Requirements
The Python X Library requires Python 1.5.2 or newer. It has been tested to various extents with Python 1.5.2 and 2.0 through 2.6.
I honestly cant explain why this works... but here is the command that got it working for me.
sudo apt-get install python3-xlib
Should not work because xlib apparently does not work with python 3.x, but everything installed alright, so I'm not complaining!
I was looking for the same answer, however after some more digging it seems that XCB (X protocol C-language Binding) will obsolete Xlib in general. From the XCB website:
The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility.
Fortunately there are python bindings available as python-xpyb in apt or xpyb on PyPi. I've not gotten that far in my project so I haven't tested if this works with Python3, but this is probably the way to go and the proper place to file any Python3 support bugs if necessary.
Scenario:
I was trying to use screenshot functionalities of pyautogui package. I was getting this error:
Traceback (most recent call last):
File "test_screenshot.py", line 1, in <module>
import pyautogui
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/__init__.py", line 152, in <module>
from . import _pyautogui_x11 as platformModule
File ".../miniconda3/envs/myenv/lib/python3.7/site-packages/pyautogui/_pyautogui_x11.py", line 7, in <module>
from Xlib.display import Display
ModuleNotFoundError: No module named 'Xlib'
Python code (test_screenshot.py):
import pyautogui
img = pyautogui.screenshot('test.png')
Environment:
Ubuntu 16.04 (LTS)
conda 4.5.11
Python 3.7 (Miniconda)
requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
PyTweening==1.0.3
Solution:
I installed python-xlib package in the conda environment using:
pip install python-xlib
Now test_screenshot.py is running without any error.
Updated requirements.txt:
certifi==2019.3.9
Pillow==5.4.1
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
PyMsgBox==1.0.6
PyRect==0.1.4
PyScreeze==0.1.20
python-xlib==0.25
PyTweening==1.0.3
six==1.12.0