To isolate my problem I run a simple two line example program that runs fine when using IDLE or other Python environment. However, whenb I try to convert the program to an executable using pyinstaller it comes with an error. The error is shown at the end of the printout. Any help to solve this problem is appreciated.
Microsoft Windows [Version 10.0.19043.1110]
(c) Microsoft Corporation. All rights reserved.
C:\>
C:\>C:\Users\John\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller example.py
88 INFO: PyInstaller: 4.4
89 INFO: Python: 3.6.5
89 INFO: Platform: Windows-10-10.0.19041-SP0
Traceback (most recent call last):
File "c:\users\John\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\John\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\John\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 124, in run
spec_file = run_makespec(**vars(args))
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\__main__.py", line 58, in run_makespec
spec_file = PyInstaller.building.makespec.main(filenames, **opts)
File "c:\users\John\appdata\local\programs\python\python36\lib\site-packages\PyInstaller\building\makespec.py", line 664, in main
with open(specfnm, 'w', encoding='utf-8') as specfile:
PermissionError: [Errno 13] Permission denied: 'C:\\example.spec'
C:\>
Permission denied: 'C:\temp.spec' is your user allowed to write to the root of the C:\ drive?
This begs the question why pyinstaller is trying to write (a temp file?) to C:\ in the first place... is that where your temp.py file (that you want to build into an .exe) is located??
Try moving temp.py to a subfolder of your My Documents, etc. and run the pyinstaller command from there.
PRO-TIP: if pyinstaller's path is listed in your PATH variable, you can call it using only pyinstaller (without the full/explicit path)
I found the problem. By mistake I used the wrong change directory command and because of that I was trying to run the pyinstaller command from the root folder of my C drive, and I don't have permission with a normal command prompt to write files there.
Wrong reference:
C:\>C:\Users\John\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller example.py
Correct reference:
C:\Users\Menachem\AppData\Local\Programs\Python\Python36\Scripts\pyinstaller example.py
Please edit your post so we can see the error clearly for the error try to run by administrator cmd if that didn't help check this
Question
Related
So I made a script that downloads a pdf from the web (via selenium), then converts said pdf table to an excel file (via tabula). I would want to share this script with people in the office however my team does not have any python/programming experience so I decided to convert the python file into an executable using Auto-Py-to-EXE. I then added a file (chromedriver) and it successfully downloaded the file.
For the conversion I used tabula to convert the PDF to a csv and xlsx file. (in the notebook/.py, the conversion worked) but when I converted the .py into an exe and ran the executable I ran into the error below.
File "tabula\io.py", line 80, in _run
File "subprocess.py", line 493, in run
File "subprocess.py", line 858, in __init__
File "subprocess.py", line 1311, in _execute_child
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "erc_scraper.py", line 126, in <module>
File "tabula\io.py", line 322, in read_pdf
File "tabula\io.py", line 91, in _run
tabula.errors.JavaNotFoundError: `java` command is not found from this Python process.Please ensure Java is installed and PATH is set for `java`
[24568] Failed to execute script 'erc_scraper' due to unhandled exception!
So I tried adding my java path to the environment path by following this link. I've added the C:\Program Files (x86)\Java\jre6\bin to the JAVA_HOME, JAVA, and PATH.
However, now I'm getting this error when I try to execute the EXE file.
Error from tabula-java:
Unable to access jarfile C:\Users\ur7634o\Desktop\erc_scraper\tabula\tabula-1.0.4-jar-with-dependencies.jar
subprocess.CalledProcessError: Command '['java', '-Dfile.encoding=UTF8', '-jar', 'C:\\Users\\ur7634o\\Desktop\\erc_scraper\\tabula\\tabula-1.0.4-jar-with-dependencies.jar', '--pages', 'all', '--guess', '--format', 'JSON', 'C:\\Users\\ur7634o\\Desktop\\ERC Data\\pdf\\qualified_contestable_customers_20220221-11-09-36.pdf']'
returned non-zero exit status 1.
[25240] Failed to execute script 'erc_scraper' due to unhandled exception!
Any advice what to do next? It seems the executable cannot read the file? I'm thinking how to make this easy also for the end-users to do this. I was just hoping the end-users can double click some shortcut to initiate the downloading and conversion of a file.
I just ran into this problem today, I tried this and it worked:
when you compile your executable, use "One Directory" option
after you are done compiling, go to the directory of your tabula package installation, copy that tabula folder into your output folder of auto-py-exe
tabula package location
that should work. What's missing is "tabula\tabula-1.0.4-jar-with-dependencies.jar" just as the error indicated. I'm not sure why auto-py-to-exe doesn't bring the tabula package over like the other packages, but I had to bring it over manually.
I am attempting to convert my python file (.py) into a Windows executable (.exe). To do this, I am using Pyinstaller. My python includes the module PyBluez for Bluetooth capabilities. When I run the command pyinstaller <path> -F from the directory of the py file, it gives an error:
FileNotFoundError: [Errno 2] No such file or directory: 'c:\users\X\appdata\local\programs\python\python37-32\lib\site-packages\pybluez-0.22-py3.7-win32.egg\bluetooth\widcomm.py'
After quite a bit of research, I am unable to figure out what is wrong with my program. Do I need to specifically specify where to find the egg file? If so, How would I do that? Thank you! Also, I tried to use cx_Freeze and it also gave an error about the bluetooth module:
Traceback (most recent call last):
File "C:\Users\X\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts__startup__.py", line 14, in run
module.run()
File "C:\Users\X\AppData\Local\Programs\Python\Python37\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.dict)
File "BuzzerBeater.py", line 3, in
ModuleNotFoundError: No module named 'bluetooth'
I had the same problem, and managed to solve it by unzipping the .egg file to a folder with the same name (including .egg in the folder name), in my case C:\Users\X\AppData\Local\Programs\Python\Python37\Lib\site-packages\PyBluez-0.22-py3.7-win-amd64.egg\.
I am trying to get a TensorFlow example (textsum) to run, and the readme.md specifies to use bazel to do the training. Ok, I dutifully installed chocolaty and then bazel, and then bazel ran and created the build files successfully. So bazel seems to work.
However when I got to the train step - also orchestrated by bazel - it choked with an IOError message that I don't really understand and can't find much information about.
Here it is:
UXIE+mike#uxie /d/tensorflow/models
$ bazel-bin/textsum/seq2seq_attention --mode=train --article_key=article --abstract_key=abstract
--data_path=data/training-* --vocab_path=data/vocab --log_root=textsum/log_root --train_dir=textsum/log_root/train
Traceback (most recent call last):
File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "bazel-bin\textsum\seq2seq_attention\__main__.py", line 168, in <module>
File "bazel-bin\textsum\seq2seq_attention\__main__.py", line 115, in Main
File "bazel-bin\textsum\seq2seq_attention\__main__.py", line 98, in CreateModuleSpace
File "C:\Python27\lib\zipfile.py", line 756, in __init__
self.fp = open(file, modeDict[mode])
IOError: [Errno 2] No such file or directory: '\\\\?\\bazel-bin\\textsum\\seq2seq_attention'
I am running this on Windows 10 in a bash shell (have tried a couple - same results everytime) and it is clearly successfully starting the python code contained in the seq2set_attention zip file (see the 2nd line that invokes that file).
However looking at the error dump it seems to get confused and suddenly it can't find that zip file anymore (see the last line).
So a few questions:
I don't remember seeing that \\\\?\\ prefix before. Googling for that string didn't help. I would like to know what it means exactly.
Why can't the executable suddenly not find the zip file it is hosted in? (if that is indeed what is happening)
Finally if you have an idea of what configuration step I might have missed, I would be grateful for any hints.
This is a bug in Bazel 0.4.5, see https://github.com/bazelbuild/bazel/issues/2708
You can build Bazel from HEAD or upgrade it to 0.5.0 release candidate to fix this.
choco install bazel --version 0.5.0-rc6
I'm trying to setup elaphe on Mac. When I try generate some barcode using the terminal, with command python + /.../file.py elaphe works OK and generates the barcode correctly. But when I try to execute through web (php) I get the following error in the Apache's error logs:
Traceback (most recent call last):
File "lib/barcode_generator/generator.py", line 19, in <module>
code_39_image.save(str(random)+'.tif')
File "/Users/x/Library/Python/2.7/lib/python/site-packages/PIL/Image.py", line 1406, in save
self.load()
File "/Users/x/Library/Python/2.7/lib/python/site-packages/PIL/EpsImagePlugin.py", line 283, in load
self.im = Ghostscript(self.tile, self.size, self.fp)
**File "/Users/x/Library/Python/2.7/lib/python/site-packages/PIL/EpsImagePlugin.py", line 72, in Ghostscript
gs.write(s)**
If I were in Windows I would say it is a problem with the path and the program can't find the "gs.write" but in Mac I'm a rookie, I don't know if it's the same, nevertheless I've already include this 2 path:
export PATH=/Users/x/Library/Python/2.7/bin:$PATH
export PATH=/usr/local/bin:$PATH
I would appreciate can give some ideas regarding this error.
Thanks in advance.
Fixed via a symbolic link. Clearly was a PATH issue or hardcoded reference to the gs binary.
sudo ln -s /usr/local/bin/gs /usr/bin/gs
If I type the following at the python.exe command prompt...
>>>help('modules')
...I get a list of available modules as expected.
However when I type the same thing in the IDLE environment (idle.pyw), it throws an error:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
help('modules')
File "C:\Python27\ArcGIS10.1\lib\site.py", line 467, in __call__
return pydoc.help(*args, **kwds)
File "C:\Python27\ArcGIS10.1\lib\pydoc.py", line 1727, in __call__
self.help(request)
File "C:\Python27\ArcGIS10.1\lib\pydoc.py", line 1766, in help
elif request == 'modules': self.listmodules()
File "C:\Python27\ArcGIS10.1\lib\pydoc.py", line 1887, in listmodules
ModuleScanner().run(callback, onerror=onerror)
File "C:\Python27\ArcGIS10.1\lib\pydoc.py", line 1938, in run
for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
File "C:\Python27\ArcGIS10.1\lib\pkgutil.py", line 105, in walk_packages
for importer, name, ispkg in iter_modules(path, prefix):
File "C:\Python27\ArcGIS10.1\lib\pkgutil.py", line 147, in iter_modules
for name, ispkg in iter_importer_modules(i, prefix):
File "C:\Python27\ArcGIS10.1\lib\pkgutil.py", line 211, in iter_modules
for fn in os.listdir(path):
WindowsError: [Error 5] Access is denied: 'C:\\WINDOWS\\system32\\Msdtc/*.*'
Why does Windows say "Access is denied" to IDLE but not the command line? I have tried using "Run as Administrator" on IDLE without success. Do I need to reconfigure IDLE in some way?
For information:
My installation of Python 2.7.2 (32-bit version running on a Windows 7 64-bit machine) came bundled with ArcGIS 10.1, which uses Python as a scripting language and certain numerical operations (via Numpy). Could this have something to do with the differing behaviour in the prompt and IDLE?
The root Python directory is: C:\Python27\ArcGIS10.1\.
IDLE is installed at C:\Python27\ArcGIS10.1\Lib\idlelib\idle.pyw.
The Python command prompt is installed at: C:\Python27\ArcGIS10.1\python.exe.
I just successfully ran help('modules') in both 2.7.8 and 3.4.2. The response depends on sys.path. It appears than ArcGIS adds C:/Windows/System32/Msdtc to the path, but you could check before running help. In any case, accessing that folder cannot be done through Windows Explorer, even when running as an admin. It requires special user action through a 'security tab'. Since MS does not want me poking around there, I did not pursue getting access. I don't know why the difference betweeon console and Idle.