I've made a program with Twython as the framework for accessing the Twitter Api. It works fine when ran as a python program, but after compiling it with py2exe, pyinstaller, and cxfreeze, it returns the same error:
File "twython\endpoints.pyc", line 169, in search
File "twython\api.pyc", line 263, in get
File "twython\api.pyc", line 257, in request
File "twython\api.pyc", line 165, in _request
twython.exceptions.TwythonError: [Errno 2] No such file or directory
I've made sure to include twython.exceptions when compiling. I cannot seem to get this thing to work properly as an executable. I've attempted on my computer and a fresh VM so there shouldn't be any installation issues. Any ideas?
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'm having a similar issue on Python 3.8.7, and I can't find the solution.
In my project, I'm using pydub.AudioSegment to get audio from a file and then exporting that audio in a different format. My code works perfectly when I'm running the python file directly. However, when I convert it to an executable with pyinstaller, run the program and get to the point of importing the audio with pydub, it gives me the following error:
Traceback (most recent call last):
File "main.py", line 269, in <module>
File "main.py", line 213, in convertfile
File "main.py", line 133, in cloud_upload
File "pydub\audio_segment.py", line 728, in from_file
File "pydub\utils.py", line 274, in mediainfo_json
File "subprocess.py", line 804, in __init__
File "subprocess.py", line 1142, in _get_handles
OSError: [WinError 6] The handle is invalid
pydub call in my program looks like this:
sound = AudioSegment.from_file(filepath)
sound.export(new_filepath, format="ogg",codec='libopus')
I've tried to add stdin=subprocess.DEVNULL and stdin=subprocess.PIPE in utils.py on line 274, but that didn't work either. Maybe I added them incorrectly, though, so suggestions like that are also highly appreciated.
I've managed to solve the problem only by removing --onefile option from pyinstaller and dropping ffmpeg.exe and ffprobe.exe into the resulted folder with the main.exe file.
That's not a good solution to the problem as I'd still prefer to use --onefile; but it works.
I'm still open to suggestions on how to make it work with --onefile or just generally why this is hapenning.
Chances are is that PyInstaller cannot recognize the imported plugin. Although if you are trying to make a app, I suggest using a shortcut instead, it is better due to the fact that you can customize the icon for the shortcut. It is what many apps mainly use.
I'm creating .exe file with pyinstaller, when I run the created .exe file , the error is shown in the console:
ValueError: No backend available.
In develop I don't have this problem.
I found that copying the libusb-1.0.dll file to C:\Windows\System32 or C:\Windows\SysWOW64 should work, but this does not work for me.
another solution is download and install libusb-win32-devel-filter-1.2.6.0.exe. It does not work for me either.
I'm using Python 3.7 and import library pyftdi
from pyftdi.spi import SpiController, SpiIOError
Any idea what else can I do?
Actual results in my console is:
File "site-packages\pyftdi\spi.py", line 319, in configure
File "site-packages\pyftdi\ftdi.py", line 471, in open_mpsse_from_url
File "site-packages\pyftdi\ftdi.py", line 309, in get_identifiers
File "site-packages\pyftdi\usbtools.py", line 342, in parse_url
File "site-packages\pyftdi\ftdi.py", line 390, in find_all
File "site-packages\pyftdi\usbtools.py", line 58, in find_all
File "site-packages\pyftdi\usbtools.py", line 231, in _find_devices
ValueError: No backend available
Failed to execute script view
The same problem had also baffled me for quite a while until I found by searching the talks happened there. It might help you.
Essentially, a walkaround is to use --add-binary command option to add libusb0.dll from system32 directory to dist directory of the pyinstaller output.
Use --add-binary command to make libusb0.dll in the .exe file. My cmd is like this:
pyinstaller -F -w main.py --add-data "libusb0.dll;."
I use google drive application wrote a desktop application using python and everything works fine. But when I use pyinstaller to output a .exe file and run that application. A problem occurs on these lines:
if credentials is None or credentials.invalid:
credentials = run(FLOW, storage)
The authentication page shows and I allow its access. Unlike usual, there is no response after that and I found that the .exe program exits with no reason.
Anyone met this problem before? If so, how to solve it?
P.S. I traced the error now and it is as follows:
Traceback (most recent call last):
File "<string>", line 697, in <module>
File "<string>", line 562, in __init__
File "build\bdist.win32\egg\oauth2client\tools.py", line 166, in run
File "build\bdist.win32\egg\oauth2client\client.py", line 1069, in step2_exchange
File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 1544, in request
File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 1294, in _request
File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 1230, in _conn_request
File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 984, in connect
File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 80, in _ssl_wrap_socket
File "USB\build\pyi.win32\USB\outPYZ1.pyz/ssl", line 381, in wrap_socket
File "USB\build\pyi.win32\USB\outPYZ1.pyz/ssl", line 141, in __init__
ssl.SSLError: [Errno 185090050] _ssl.c:340: error:0B084002:x509 certificate rout
ines:X509_load_cert_crl_file:system lib
I saw someone encountered the similar error http://code.google.com/p/google-api-python-client/issues/detail?id=58 but the reply said it already fixed it.
I also tried the method in https://github.com/kennethreitz/requests/issues/557 but it is not working.
Does anyone know how to fix it?
I'm guessing, but this is possible related to STDIN handling on Windows exe from pyinstaller - usually this won't be available to you, so you might have to run your own custom flow.
But you can narrow it down to either:
Reading/writing from STDIN/STDOUT
Starting a local web server
Launching a browser
Since all those need to be performed when running a flow locally, and one of them is going wrong for you.
If you log STDERR to a text file, you will be able to see which part is crashing.
After digging a little bit, I found the solution based on solution provided by Dropbox api developer: https://forums.dropbox.com/topic.php?id=65523&replies=1#post-461457. This problem is basically caused by:
CA_CERTS = os.path.join(os.path.dirname(os.path.abspath(__file__ )), "cacerts.txt")
__file__ is the key that causes this problem. It cannot work normally in the executable program to find the path.
Similar problem can be found here: pyinstaller seems not to find a data file
In order to solve this problem, I change the above code into this:
CA_CERTS = os.path.join(os.path.dirname(sys.executable), "cacerts.txt")
By doing this, the .exe program will try to find cacerts.txt in the directory where .exe file is located. After compiling this into .pyc, I put cacerts.txt into .exe directory. Then the program can run normally.
I have Mercurial 1.8.1, Python 2.6.6 installed on Win 2k8 R2 running on a vm. I have tried installing from msi, source and using tortisehg. Command-line Hg works fine but I get the same error when running the hgweb.cgi:
Traceback (most recent call last):
File ".\hgweb.cgi", line 17, in
application = hgweb(config)
File "mercurial\hgweb\__init__.pyc", line 26, in hgweb
File "mercurial\hgweb\hgwebdir_mod.pyc", line 61, in __init__
File "mercurial\hgweb\hgwebdir_mod.pyc", line 70, in refresh
File "mercurial\ui.pyc", line 35, in __init__
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\util.pyc", line 576, in
File "mercurial\demandimport.pyc", line 85, in _demandimport
File "mercurial\windows.pyc", line 21, in
File "mercurial\demandimport.pyc", line 75, in __getattribute__
File "mercurial\demandimport.pyc", line 47, in _load
File "mercurial\osutil.pyc", line 12, in
File "mercurial\osutil.pyc", line 10, in __load
ImportError: DLL load failed: The specified module could not be found.
The other answers I have found on SO and elsewhere pointed me to try installing from source, dropping the pure osutil into the install, or installing an older version. I have tried them all.
This is especially frustrating because I have other, similar non-vm machines running fine but have been unable to find the disconnect.
Ideas?
I had the same error using following system configuration
Python-2.6.6 installed as msi
mercurial-1.8.2-x86 installed as msi
IIS7
I solved this problem simply:
Python has been installed early
Uninstall Mercurial msi package
Download and install "Mercurial-1.8.2 (32-bit py2.6)" installer from mercurial website which is marked as "This is recommended for hgweb setups".
copyed content of C:\Python26\Lib\site-packages\mercurial\ to the directory used in IIS7 website setup.
Till now all is working. Hope this will help.
Whenever I have less than descriptive error messages that tell me something is going on at the system level but not what, I use Sysinternals' Procmon to tell me what's going with the registry and filesystem. It's verbose, and getting the filter to show just the process of interest takes some learning, but you can export the results to Excel and skim them for suspicious-looking results. Pay particular attention to failures, of course.
Give it a try and see what DLL is being searched for.