I am new to Python. I wanted to use svm for my project. I was using libsvm 3.12 but when i do ..
from svm import *
then i get the following error :
Traceback (most recent call last):
File "C:/Python27/main.py", line 31, in
from svm import *
File "C:/Python27\svm.py", line 12, in
libsvm = CDLL(find_library('libsvm'))
File "C:\Python27\lib\ctypes\__init__.py", line 353, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
What should I do?
The libsvm README file suggested that I copy libsvm.dll into the system32 folder, which I did .. but still I am getting the error. I am using 64 bit Python. Maybe that is causing the problem?
I just had the same issue.
As Velociraptors posted in VLC Python Bindings -- Error 193:
I'm going to guess that the problem is trying to load a 32-bit DLL from a 64-bit process. You may be able to fix it by using a 32-bit Python build.
We solved the issue by downloading libSVM for python from http://www.lfd.uci.edu/~gohlke/pythonlibs/#libsvm
Related
I tried to read the text from the image using Pytesseract.I am getting Access denied message when I run the below script.
from PIL import Image
import pytesseract
import cv2
import os
filename=r'C:\Users\ychandra\Documents\teaching-text-structure-3-728.jpg'
pytesseract.pytesseract.tesseract_cmd = r'C:\Python27\Lib\site-packages\pytesseract'
image=cv2.imread(filename)
gray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
gray=cv2.threshold(gray,0,255,cv2.THRESH_BINARY|cv2.THRESH_OTSU)[1]
gray=cv2.medianBlur(gray,3)
filename='{}.png'.format(os.getpid())
cv2.imwrite(filename,gray)
text=pytesseract.image_to_string(Image.open(filename))
print text
cv2.imshow("image",image)
cv2.imshow("res",gray)
cv2.waitKey(0)
when I run the script I am getting below Error
Traceback (most recent call last):
File "F:\opencv\New_folder_3\text_from_image.py", line 17, in <module>
text=pytesseract.image_to_string(Image.open(filename))
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 122, in image_to_string
config=config)
File "C:\Python27\lib\site-packages\pytesseract\pytesseract.py", line 46, in run_tesseract
proc = subprocess.Popen(command, stderr=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 5] Access is denied
Your code works except the setting of pytesseract.pytesseract.tesseract_cmd. The tesseract_cmd should set to the tesseract executable file installed in your machine.
Here is a sample usage of it.
pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract 4.0.0/tesseract.exe"
The tesseract_cmd is required if no properly search PATH setup in your Windows PC.
Hope this help.
UPDATE:
You need to have tesseract binary installed into your PC before using pytesseract which uses subprocess module to run tesseract in Windows shell from Python.
Click this Tesseract 4.00 alpha to download a 64-bit Windows version and install it. Then setup the PATH and TESSDATA_PREFIX pointing to your tesseract.exe and ~\tessdata directory respectively.
If you need any other language trained data file, you can get it [here].
In case the ~\tessdata directory is not found in your Windows, you can create it manually and copy at least one traineddata file to there, such as eng.traineddata for English.
If tesseract is working, it will return the version information when you type tesseract -v in command prompt as below.
I'm trying to run a code as described here.
I have a anaconda enviroment with tensorflow installed via pip installation.
When trying to run the example on the link provided I have a issue. The first one was that the file:ptb_word_lm.py wasn't present on my installation. I just copied the file from github and tried to run anyway. I got the following error when running python ptb_word_lm.py --data_path=/tmp/simple-examples/data/ --model small
error message:
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
I tensorflow/stream_executor/dso_loader.cc:105] Couldn't open CUDA library libcudnn.so. LD_LIBRARY_PATH: /lib/x86_64-linux-gnu:/home/danielmoreira/anaconda2:/home/danielmoreira/anaconda2/lib:/usr/local/cuda-7.5/lib64:
I tensorflow/stream_executor/cuda/cuda_dnn.cc:3448] Unable to load cuDNN DSO
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally
Traceback (most recent call last):
File "ptb_word_lm.py", line 361, in <module>
tf.app.run()
File "/home/danielmoreira/anaconda2/envs/tensorenv/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "ptb_word_lm.py", line 321, in main
train_input = PTBInput(config=config, data=train_data, name="TrainInput")
File "ptb_word_lm.py", line 85, in __init__
self.input_data, self.targets = reader.ptb_producer(
AttributeError: 'module' object has no attribute 'ptb_producer'
I have found people on google suggesting to change the line from tensorflow.models.rnn.ptb import reader to just import reader, but it doesn't seem to work for me.
Does anyone know the possible solution?
I'm using Python 2.7.12 and Tensorflow version seems to be 0.11.0rc2
I am getting started with pythonocc i have tried to import some modules and return with the following errors
` Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from OCC.gp import *
File "C:\Python27\lib\site-packages\OCC\gp.py", line 28, in <module>
_gp = swig_import_helper()
File "C:\Python27\lib\site-packages\OCC\gp.py", line 24, in swig_import_helper
_mod = imp.load_module('_gp', fp, pathname, description)
ImportError: DLL load failed: The specified module could not be found.
`
i am using windows 64 bit python 2.7.3 32bit and pythonocc 0.5 all in one
What is the solution to the above probelm?
If you have 64 bit python, it can struggle to load 32 bit Dll's.
Try this link
I recommend getting a 32 bit distribution of python, this should solve your problem
Install pythonocc 0.6 from this link http://code.google.com/p/pythonocc/ this should work fine
At the following link you can find pythonOCC for Python 2.7:
http://code.google.com/p/pythonocc/downloads/list
Link was tested on 07/10/14
I am trying to use a C++ dll in python. I am running python 2.7 on Windows server 2012; both are 64bit.
To create a dll, I followed the directions on "Walkthrough: Creating and Using a Dynamic Link Library (C++)" on http://msdn.microsoft.com/en-us/library/vstudio/ms235636.aspx. I used their example code. I am new to dlls and python so I thought I would start with examples.
My python code:
from ctypes import *
hw = CDLL("Y:\dll_check\MathFuncsDll.dll")
print "HelloWorld"
I get the following error:
Y:\dll_check> python .\MathFuncsMain/py
Traceback (most recent call last):
File ".\MathFunsMain.py"
libimgr = CDLL("Y:\dll_check\MathFuncsDll.dll")
File "C:Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 is not a valid Win32 application
What is causing my error?
use 32 bit python version and compile to resolve the issue.
Reason(probably) : even though your machine is 64-bit; the dll you have created is a 32 bit one. bcz through visual studio you can select and create only "Win32 application".
I recently installed EPD 7.3-2 (the free version) on my Ubuntu 12.04 (64 bits).
I have some problems when trying to use ipython, I got the following error :
ImportError: Gtk* backend requires pygtk to be installed.
SO I found this article :
https://support.enthought.com/entries/22961778-epd-for-mac-os-x-32-and-64-bit-versions
and even thought it is for Mac OSX it did worked on my Linux machine. The modifications I did was putting the backend like this :
backend : Qt4Agg #GTKAgg
backend.qt4 : PySide
So it used to be GTKAgg. But now I have a new problem. When I try to plot with pylab a simple plot, like :
from pylab import *
plot([1,2,3])
show()
Nothing pops up... And I get the following error :
Error in atexit._run_exitfuncs: Traceback (most recent call last):
File
"/home/mela/Librairies/epd_free-7.3-2-rh5-x86_64/lib/python2.7/atexit.py",
line 24, in _run_exitfuncs
func(*targs, **kargs) File "/home/mela/Librairies/epd_free-7.3-2-rh5-x86_64/lib/python2.7/site-packages/matplotlib/_pylab_helpers.py", line 82, in destroy_all
manager.destroy() File "/home/mela/Librairies/epd_free-7.3-2-rh5-x86_64/lib/python2.7/site-packages/matplotlib/backends/backend_qt4.py",
line 367, in destroy
self._widgetclosed )
RuntimeError: Internal C++ object (PySide.QtGui.QMainWindow) already deleted.
Error in sys.exitfunc:
Traceback (most recent call last): File
"/home/mela/Librairies/epd_free-7.3-2-rh5-x86_64/lib/python2.7/atexit.py",
line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/home/mela/Librairies/epd_free-7.3-2-rh5-x86_64/lib/python2.7/site-packages/matplotlib/_pylab_helpers.py", line 82, in destroy_all
manager.destroy()
File "/home/mela/Librairies/epd_free-7.3-2-rh5-x86_64/lib/python2.7/site-packages/matplotlib/backends/backend_qt4.py",
line 367, in destroy
self._widgetclosed )
RuntimeError: Internal C++ object (PySide.QtGui.QMainWindow) already deleted.
And I really don't get what does it mean or what should I do.
Any clue would be appreciated.
So I found my problem.
First of all, from the problem I undestand that it tries to close a window that's already closed, so I searched why and it looks like now the displays of pyplot are supposed to close directly after so when I add pl.show(block=True). Now I have a display but also a segmentation fault.
After trying different backends it looks like TkAgg solves both problems. So no compatibility issues and I can see my plots.
PS : for changing the backend from matplotlib go to ~/.matplotlib and edit the file matplotlibrc