Py2exe Pywin32 Error - python-3.x

Py2exe perfectly converts python scripts to windows executable, unless the file includes pywin32. In that case, it shows a RuntimeError:
RuntimeError: maximum recursion depth exceeded in comparison
All other python files are having no trouble with py2exe.
So, Is there any way to make py2exe work with pywin32?
Note: I've tried increasing recursion depth limit, it doesn't work.

Related

Issue making .exe with Pyinstaller : compilation is done but the .exe fails

I have a rather large python script that I would like to convert to .exe. I use PyInstaller and I managed to import every library needed so now I don't get any error message. My problem is that at some point, the .exe is stuck, so the conversion with PyInstaller didn't really worked. I suspect the issue is related to the PyAutoGui library, but I had to import it to convert my python script (I used pip install).
Does anyone else got the same issue? Is there something I can do to remove this issue?
I have python 3.9.2 and pyinstaller 4.2 and I am working with windows 10.
The libraries I had to import are : pyautogui, pandas, bs4, pygame, PyQt5, pywin32, winshell, pymysql, sqlalchemy, sqlalchemy.sql.default_comparator, wmi, Pillow, psutil and lxml.
Thanks for your suggestions!
In my experience, PyInstaller has had trouble generating .exe files from python scripts that use graphics libraries such as pygame and PyQt5. Mostly, it fails to generate the .exe and even when it does, the .exe takes a long time to load up and is really slow. If you want an .exe file, I would suggest trying out cx_freeze. To my knowledge, it won't generate .exe in one file like pyinstaller does, but the .exe file it does generate is of much higher quality.
We think we found the issue: pyautogui needs an other package called open-cv to work. Hope it'll help someone someday ;-)

Python packaging with Pyinstaller

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.

Python 3 virtual environment is executing python 2

This issue has had me scratching my head for a while now.
I've encountered this problem twice now, on windows 7 and windows 10. As its a closed network I've no security concerns with W7.
I have an existing Python 2.7 install - densely populated, with some fairly old library versions.
Whilst I would like to create a virtual environment for Python 2.7 I'm reluctant to do so because wheels are not available for many of the library versions I need to use, and revision histories do not appear to be available for some of these older libraries either, so without trying them I can't tell if the later library versions are backwards compatible or not. As the Python 2.7 code is from a production environment I can't break/replace it.
The python 2.7 libraries are all installed from executable installers as many of them predate
the introduction of the python wheel standard. Some also require to be built with older versions of MSVC, which is another reason for not wanting to attempt to rebuild.
It will be much easier to leave the python 2.7 install as is and start running Python 3 in virtual environments, although my original plan was to create a separate 2.7 virtual environment.
Example Python 3 virtual environment created as "py37".
In my virtual environment.
include-system-site-packages = false
When I activate the virtual environment all appears to be good.
Python -V returns 3.7.3, which is what I expect
I modified my script to output the python version (so I can track what is happening)
(py37) C:\my_folder\my_script.py
3.7.3 (v3.7.3:ef4c6ed12, Mar 25, 2019, 21:26:53) [MSC v.1916 32 bit (Intel)]
Traceback (most recent call last):
file "my_script.py", line 24, in (module)
from tk import ttk
ModuleNotFoundError: No module named 'tk'. 'tk' (python 3 lib) is not being found.
I then created two simple scripts, one using the python 2 print format, the other python 3.
Even though the virtual environment says python 3, and the python version says 3.7.3 the python 3 script fails to run.
The python 2 version of print prints out correctly, so clearly even though all indications are that Python 3 is running, it's actually Python 2.
PythonPath is null/not defined on the PC and my path variable points to my python 3 virtual environment, not my Python 2 install.
All the searching and examples I have come up with stop when version() or Python -V returns 3.x, so if it is a duplicate issue I've not managed to find the original request.
The solution to this was simple, but unpleasant.
In order for everything to work as it should I needed to explicitly identify the executable I wanted to run, every time I wanted to run it i.e. full path to the python executable in my python3 virtual environment.
I ended up creating a batch file wrapper to facilitate this
e.g. c:\apps\my_venv3\scripts\python.exe %*
Clunky, but it works, reliably, and does not break any of the existing environments.

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)

python3 importing pygame results in PyCObject_AsVoidPtr

I have encountered difficulty putting pygame together with python3 on my MacBookPro.
I installed Python 3.3, and my MacOS is running version 10.7.5.
Then I downloaded pygamev1.9.1 source code, and followed instructions in http://programming.itcarlow.ie/PyGameInstall.pdf
Compilation and installation was smooth until I issued "import pygame" inside python3.
Then I encountered the following "PyCobJect_AsVoidPtr" error (further text following error message):
import pygame
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/init.py", line 95, in
from pygame.base import *
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so, 2): Symbol not found: _PyCObject_AsVoidPtr
Referenced from: /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pygame/base.so
A search on google indicates this symbol has been removed since Python3.2:
http://mail.python.org/pipermail/python-dev/2011-March/108882.html
Can someone please give me some advice on how to get pygame working on Python3.3?
More so, whereas I am aware the pygame/python3 developers are busy with their work, but I would certainly appreciate it if someone can provide precompiled pygame binaries for python3. I have limited computer skills, and I just want to go ahead and learn Python3 and pygame, and this is seriously stunting my interest.
I notice that you were trying to compile from source, but builds on Python 3.3, to my knowledge, are not yet supported (as of January 2013). In fact, the only binaries I'm aware of for PyGame and Python 3.3 are unofficial builds and Windows only.
You should consider instead using a previous version of Python (e.g. Python 2.7.*), PyGame builds/binaries on which are well-supported. Any points on setting up should be directed to the pygame-users mailing list, if they weren't already.

Resources