I am running this code in a debian/jessie box:
from elaphe import barcode
text = 'hello world in barcode'
bc = barcode('pdf417', text, options = dict(
compact = False, eclevel = 5, columns = 13,
rowmult = 2, rows = 3),
margin=20, scale=1)
After running this, I execute the following:
bc.save('filename.png')
And then get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1653, in save
self.load()
File "/usr/lib/python2.7/dist-packages/PIL/EpsImagePlugin.py", line 336, in load
self.im = Ghostscript(self.tile, self.size, self.fp, scale)
File "/usr/lib/python2.7/dist-packages/PIL/EpsImagePlugin.py", line 143, in Ghostscript
stdout=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 2]
No such file or directory
If I run the same code in an ubuntu 14.04 box, there is no such error and works fine. Since I saw this error appearing in several post, and with lots of packages, I can conclude that it's something related to debian and not to the code itself, not even to elaphe python package.
It would be desirable to find if there is some kind of path to redefine or symlink somewhere, or if there is a patch for this.
Please help.
The error message is not super clean. But it might be caused by missing ghostscript package.
try:
sudo apt-get install ghostscript
Related
I wanted to run a python script from my Java Maven project. Simple python scripts works fine without any issues.
But if i try something complicated like using OpenCV and pytesseract libraries to do some image recognition related tasks the code doesn't work.
The python script works fine if i just run it from the terminal (i have installed all the required libraries)
But the same script when called from the Java Maven project, it doesn't work.
Here is the code:
String path = "/Users/team/Desktop/my.py";
ProcessBuilder pb = new ProcessBuilder("python3","/Users/team/Desktop/my.py").inheritIO();
Process p = pb.start();
p.waitFor();
BufferedReader bfr = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = bfr.readLine()) != null) {
System.out.println(line);
}
It is throwing below error:
Traceback (most recent call last):
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 252, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args())
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'tesseract'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/team/Desktop/my.py", line 73, in <module>
result = pytesseract.image_to_string(Image.open(src_path + "thres.png"))
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 413, in image_to_string
return {
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 416, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 284, in run_and_get_output
run_tesseract(**kwargs)
File "/Users/team/Library/Python/3.8/lib/python/site-packages/pytesseract/pytesseract.py", line 256, in run_tesseract
raise TesseractNotFoundError()
Could someone please help me figure this out please? I feel like the issue is because of some sort of PATH, but not sure how to fix it!
Would you mind trying using -Djava.library.path= so the java process knows where to locate the tesseract library.
I have been trying to install the mlabwrap Python library, but keep on running into the following error when I run the setup.py file using the command python setup.py install in the terminal:
Traceback (most recent call last):
File "setup.py", line 130, in <module>
queried_version, queried_dir, queried_platform_dir = matlab_params(cmd, WINDOWS, extra_args)
File "setup.py", line 93, in matlab_params
error = call(cmd, **extra_args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I have done some investigation, and found the following forum post: https://sourceforge.net/p/mlabwrap/mailman/message/29077359/ to resolve the issue. Following the advice in this thread, I changed the following things in the setup.py file:
__version__ = '7.3'
and
MATLAB_DIR = '/Applications/MATLAB_R2015a.app'
I have a feeling that the problem is related to finding the directory that matlab is located in, but I seem to be unable to resolve this. I didn't change my $PATH variable because I was a little confused by the advice given in the thread. Any insight would be much appreciated!
In order to install mlabwrap, you must modify the setup.py file to:
MATLAB_COMMAND = '/Applications/MATLAB_R2015a.app/bin/matlab' # specify a full path if not in PATH
MATLAB_VERSION = 7.3 # e.g: 6 (one of (6, 6.5, 7, 7.3))
# 7.3 includes later versions as well
MATLAB_DIR= '/Applications/MATLAB_R2015a.app/' # e.g: '/usr/local/matlab'; 'c:/matlab6'
PLATFORM_DIR='maci64' # e.g: 'glnx86'; r'win32/microsoft/msvc60'
EXTRA_COMPILE_ARGS=None # e.g: ['-G']
The parameters may change depending on what version of MATLAB you are using and what operating system you are using.
How do I run/install this: https://github.com/kevmoo/kbuild?
I installed the dependencies and tried to execute the bin/kbuild Python script, but it's giving me this error:
Traceback (most recent call last):
File "kbuild/bin/kbuild", line 12, in <module>
BREW_PREFIX = subprocess.check_output(['brew', '--prefix']).strip()
File "/usr/lib/python2.7/subprocess.py", line 537, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
raise child_exception OSError: [Errno 2] No such file or directory
My guess is that this tool was intended for OSX and Homebrew and that's why it's choking. I just wasn't sure based on the minimalist installation instructions.
Line 12:
BREW_PREFIX = subprocess.check_output(['brew', '--prefix']).strip()
is explicitly trying to run 'brew' in the shell, so yes I'd say it is written only for OSX.
I'd suggest you wait for your Issue to be answered on GitHub, or try modifying it yourself. It seems brew is only being used to check for available compilers.
I am working with WARC Tools, a python library for working with WARC files. I've installed everything and it all seems to work except for the last command. While I suspect many of you may not have worked with this tool, perhaps you can make sense of the error message for me.
When I run this command:
python /path/filesdump.py filtered.warc as per the documentation, I get this error message immediately:
html/811cac8c-7430-403b-96a4-7d77137b0d46.html
Traceback (most recent call last):
File "/users/ianmilligan1/desktop/warc/warc-tools-mandel/filesdump.py", line 63, in <module>
sys.exit(main(sys.argv))
File "/users/ianmilligan1/desktop/warc/warc-tools-mandel/filesdump.py", line 34, in main
dump_archive(fh,name)
File "/users/ianmilligan1/desktop/warc/warc-tools-mandel/filesdump.py", line 57, in dump_archive
txt = record.filedump(content=True)
File "/Users/ianmilligan1/Desktop/WARC/warc-tools-mandel/warctools/record.py", line 140, in filedump
p = Popen(['lynx', '-dump', '-stdin', '-nomargins', '-unique_urls', '-width=120'], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1228, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
What's going on here? Where would you suggest I begin looking?
You need to install lynx, a command-line web browser that WARC Tools seems to require. That'll solve it.
What's going on is that warctools/record.py is calling lynx on line 140, and Python's subprocess library isn't finding the lynx executable so it throws an exception. They really ought to wrap the exception and provide a clearer message... Anyways. Try that and see if it fixes it.
I am trying to build adblockplus from this link. When I issue the command:
python build.py build
I end up getting the following error message. I tried with and without sudo to no avail.
Traceback (most recent call last):
File "build.py", line 10, in <module>
buildtools.build.processArgs('.', sys.argv)
File "/home/machine/projects/weird/buildtools/build.py", line 352, in processArgs
commands[command](baseDir, scriptName, opts, args, type)
File "/home/machine/projects/weird/buildtools/build.py", line 39, in __call__
return self._handler(baseDir, scriptName, opts, args, type)
File "/home/machine/projects/weird/buildtools/build.py", line 166, in runBuild
limitMetadata=limitMetadata)
File "/home/machine/projects/weird/buildtools/packager.py", line 274, in createBuild
buildNum = getBuildNum(baseDir)
File "/home/machine/projects/weird/buildtools/packager.py", line 80, in getBuildNum
(result, dummy) = subprocess.Popen(['hg', 'id', '-n'], stdout=subprocess.PIPE).communicate()
File "/usr/lib/python2.6/subprocess.py", line 623, in __init__
errread, errwrite)
File "/usr/lib/python2.6/subprocess.py", line 1141, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Am I missing a package? Any hint on what the problem could be will be much appreciated.
The stack trace makes it clear that the issue is caused by the following line:
(result, dummy) = subprocess.Popen(['hg', 'id', '-n'], stdout=subprocess.PIPE).communicate()
If you look at the subprocess package documentation, this line is trying to run the hg id -n command (get numerical Mercurial revision). Apparently, the Mercurial command line tool isn't present on your system (a possibility that this build script didn't consider) so it fails.
Disclaimer: I happen to be the one who wrote this script and I fixed this bug now. Mercurial isn't essential for the build, the revision number is pretty much only necessary to determine the output file name.