Python packaging with Pyinstaller - python-3.x

I am trying to package my python file using Pyinstaller. I follow the instructions from this link
https://datatofish.com/executable-pyinstaller/
but I get this error.
RecursionError: maximum recursion depth exceeded.
I tried to added the following line of code as it was suggested on few pages but so far no success.
**import sys
sys.setrecursionlimit(1500).**
Any help?

Just so you all know the error was caused by Anaconda environment. It is not compatible with Python 3.7 and Pyinstaller. As soon I as uninstall Anaconda and run the Pyinstaller function, everything was fine and I managed to create an exe file.

Related

Getting error when using pynput with pyinstaller

A friend of mine asked me to write him a program, and I used pynput to handle some of the inputs and other features. When I convert the program an executable with pyinstaller, launcing the executable gives me this error: File "site-packages\pynput\keyboard\__init__.py", line 31, in <module> File "site-packages\pynput\_util\__init__.py", line 82, in backend ImportError [11492] Failed to execute script friend_project
I have tried using the pyinstaller command pyinstaller --onefile friend_project.py, and also using auto-py-to-exe to run it.
Using pyinstaller with other modules like pygame or pyopengl gives me no error, but this one module does.
Running the script by it self with the python inturpeter works fine, but I would perfer to have it be an exe so I can give it to him with out him needing python to run it.
Please fall back to 1.6.8 version of pynput.
pip install pynput==1.6.8
If you are running Windows you need to add these parameters to the command line (for the first time, after that they will be included in the generated spec file).
--hidden-import "pynput.keyboard._win32" --hidden-import "pynput.mouse._win32"
For Linux, use:
--hidden-import "pynput.keyboard._xorg" --hidden-import "pynput.mouse._xorg"
More information can be found in this Github issue.

fbs freeze failed with Python 3.6.4

I have the following problem with fbs and Python: I tried to compile Python code and wanted to create an executable .exe file in windows. The command fbs run works fine, but fbs freeze fails.
Package versions:
Python 3.6.4
PyInstaller: 3.4
PyQt5: 5.9.2
Packages that I import:
import re
from itertools import chain
import os
import pandas
from PyQt5.QtWidgets import *
from fbs_runtime.application_context.PyQt5 import ApplicationContext
The output of fbs freeze --debug you see in the attached image:
I used the pyinstaller command to create the exe. This was possible without fbs. Just pyinstaller with the standard comments pyinstaller "...." --onefile --noconsole.
It worked with Python 3.6.4 and pyinstaller 3.4. Perhaps 3.5 would also work. But I know at least that Python 3.8.0 with the newest pyinstaller (even development version from git) doesn't work. I used PyQt5, but some older version 5.12....
It's a bit intransparent...
Best regards,
Markus
fbs runs perfectly fine with python 3.6.x (I am using 3.6.8, PyQt 5.9.2, PyInstaller 3.4).
The python compiler can sometimes get confused if another error happens earlier in the stack. Generally if fbs freeze errors when fbs run works, that points to a library-include error.
See my answer here to include necessary python library resources in your ./src/freeze/windows/ directory and try freezing again: The 'google-api-python-client' distribution was not found and is required by the application with pyinstaller

Pyinstaller development version: recursion depth reached

With due reference to question at Pyinstaller Maximum Recursion Depth Exceded, I removed all versions of pyinstaller and associated folders. I installed the newest development version of pyinstaller with:
pip install https://github.com/pyinstaller/pyinstaller/tarball/develop
Using pyinstaller still causes this error message:
RecursionError: maximum recursion depth exceeded.
I am using Python 3.6.4. I've seen that others downgrade to Python 3.5. Others suggest increasing the recursion depth in the spec file (http://pyinstaller.readthedocs.io/en/stable/spec-files.html).
Can anyone suggest the best path forward?
FWIW, I ripped out Python 3.6.4 and installed Python 3.5.2. Now, pyinstaller and P3.5.2 play well together.
Alternatively, you can increase the recursion limit by adding the following to the beginning of the .spec file:
import sys
sys.setrecursionlimit(5000)

PyCharm 2017.1, No module named 'kivy'

I could use (troubleshooting)help with getting Kivy imported in PyCharm. I am using:
Anaconda with Python 3 on 64-bit Windows 10 Pro
PyCharm 2017.1
Packages: NumPy, SciPy, BeautifulSoup, Pandas, Scrapy, Pattern, NetworkX, NLTK, scikit-learn, Selenium
I have installed Kivy following the instructions at https://kivy.org/docs/installation/installation-windows.html#installation
As evident from the screen shot, no errors occurred.
Still, when I run "import kivy" from PyCharm I get "ModuleNotFoundError: No module named 'kivy'".
I ran through the installation with someone on the #kivy channel and was assured that kivy is successfully installed.
When I pass import kivy; print(kivy.file) to the interpreter (opened from the CMD command line), I get returned among others:
C:\Users\Steve\Anaconda3\lib\site-packages\kivy\__init__.py
Someone on #kivy suggested I check where PyCharm looks for kivy. How do I figure that out?
I'd appreciate any suggestions to identify the problem / resolve my issue.
Indeed, the installation of Kivy went fine. The problem turned out to be that I had to select the correct (updated) interpreter in the PyCharm settings.

Pyinstaller Cannot find xlrd

I am running Python 3.5.1 and PyInstaller 3.2 on Windows.
I need to compile my script into an exe. I have done this with pyintaller before with different scripts and have had no issues. Pyinstaller is having trouble importing xlrd. I have tried:
--hidden-import=xlrd
and also
--hidden-import xlrd and neither has worked.
I have heard about hooks but I cannot find any documentation on how to set up the hook-xlrd.py file.
I have been getting the error:
ImportError: No Module called xlwt
The script runs perfectly from the Command Prompt.
Somehow, your application requires xlwt. So do a pip install xlwt and then add --hidden-import=xlwt to your arguments. For a more comprehensive guide, see here.

Resources