I finished my code on Pycharm. Now I want to convert my .py file into .exe
After i converted it. The application file are running on the desktop (desktop1) that I used to convert, but when i try to open the application on other desktop (desktop2) it has an error that says.
`Traceback (most recent call last):
File "main.py", line 220, in <module>
obj = DocumentsManagementSystem(root)
File "main.py", line 20, in __init__
self.root.iconbitmap(r'C://Users//HP//PycharmProjects//pythonProject1//Images//senglogo.ico')
File "tkinter\__init__.py", line 2109, in wm_iconbitmap
_tkinter.TclError: bitmap "C://Users//HP//PycharmProjects//python`
but when i open it on the desktop (desktop1) it is running. That's the issue. I cannot open it on other desktop. If you have any idea on how i can solve this. I will gladly do it. Thank you so much!
Use pyinstaller with additional file and add-data parameters. In your case use this command:
pyinstaller --add-data '//Users//HP//PycharmProjects//pythonProject1//Images//senglogo.ico:.' script.py
It seems like you missed adding an additional and data file in your pyinstaller process.
if you're beginner you can use the GUI of pytinstaller.
https://pypi.org/project/auto-py-to-exe/
The required steps for py to exe.
Analysis: Finding the Files Your Program Needs
https://pyinstaller.org/en/stable/operating-mode.html#analysis-finding-the-files-your-program-needs
Add required file by using this command:
pyinstaller --add-data 'src/README.txt:.' myscript.py
Related
I made an exe to read images including gifs using pyinstaller. However, the exe can't read gif and the below error occurs. I have installed the latest version of imageio and the program works in interpreter. Could you advise? Thanks in advance.
The line raising error:
cv_gif = imageio.mimread(pic_path)
Error:
Traceback (most recent call last):
File "Image Viewer.py", line 3085, in <module>
File "Image Viewer.py", line 522, in go
File "Image Viewer.py", line 1264, in ShowANI
File "imageio\core\functions.py", line 247, in mimread
File "imageio\core\imopen.py", line 277, in imopen
ValueError: Could not find a backend to open `C:\Users\simon\Practice\testdir3\alpaca.gif`` with iomode `rI`.
Based on the extension, the following plugins might add capable backends:
pillow: pip install imageio[pillow]
GIF-PIL: pip install imageio[pillow]
I have exactly the same problem.
This might have something to do with the new feature of imageio introduced in version 2.11.0: Choose plugin based on extension and plugin lazy-import. Revert back to 2.10.5 solves the problem.
Just manually copied the folder \Lib\site-packages\imageio and replaced the imagoio folder of the exe, then it works.
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 am able to run my exe file but my scripts has multiple pip libraries for it to work. I always get this error when running my script.
Exception in thread Thread-1:
Traceback (most recent call last):
File "threading.py", line 932, in _bootstrap_inner
File "threading.py", line 870, in run
File "AIO_Bot.py", line 265, in main_function
File "cloudscraper/__init__.py", line 665, in create_scraper
File "cloudscraper/__init__.py", line 120, in __init__
File "cloudscraper/user_agent/__init__.py", line 20, in __init__
File "cloudscraper/user_agent/__init__.py", line 77, in loadUserAgent
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/8g/gkf53znx7_7405c26w344ftw0000gn/T/_MEIujM2ll/cloudscraper/user_agent/browsers.json'
Finished in 0.0 second(s)
If anyone knows how to fix this please help!
It seems that your browswers.json is expected to be found in a relative path from the "exe" (cloudscraper/user_agent) when it is not the case when it is really a exe file. You have to modify your pyinstaller build command to include that file in the package. Add
--add-data '/lib/python3.8/site-packages/cloudscraper/user_agent/browsers.json:cloudscraper/user_agent' and it should work. (replace : with ; on Windows)
You can refer to https://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-data-files for more details.
It seems your script/exe is looking for a file named "browsers.json".
Locate it and try putting it in the same folder as your created *.exe
The file is not being located because you are searching through a path that can not be opened. If your script is on the same level of the path then you would only have to do this
(browsers.json)
to fix this just exclude the directory path
mv /lib/python3.8/site-packages/cloudscraper/user_agent/browsers.json /var/folders/8g/gkf53znx7_7405c26w344ftw0000gn/T/_MEIujM2ll/cloudscraper/user_agent/
if this does not work pip install cloudscraper in terminal instead because pycharms assigniing the file to it's own enviroment
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 am trying to use pyinstaller 2.0 to build an .exe file from a python script which uses matplotlib and numpy, but I keep failing. I tried this code from
Building python pylab/matplotlib exe using pyinstaller
as a simple reference, I get the build done for me, but when I run the exe I get the error:
Traceback (most recent call last):
File "<string>", line 12, in <module>
File "C:\Compilations\pyinstaller-2.0\PyInstaller\loader\iu.py", line 386, in
importHook
mod = _self_doimport(nm, ctx, fqname)
File "C:\Compilations\pyinstaller-2.0\PyInstaller\loader\iu.py", line 480, in
doimport
exec co in mod.__dict__
File "C:\Compilations\pyinstaller-2.0\ptest\build\pyi.win32\ptest\out00-PYZ.py
z\PIL.PpmImagePlugin", line 27, in <module>
LookupError: no codec search functions registered: can't find encoding
Is this a bug or do I need to tinker with the .spec file and link the matplotlib libraries to pyinstaller somehow? If so - can anyone show me a simple example, please?
I tried cx_Freeze before and also seem to have a problem as soon as I use a code with matplotlib.
Thanks in advance!
Edit PpmImagePlugin.py and add 'import encodings' (without the quotes) before any other imports. I had the same problem and this fixed it. Source: http://www.pyinstaller.org/ticket/651