New error trying to compile pygame to exe - python-3.x

I have created a small game for my little boy using Python 3.4 and Pygame in Windows 7. It also works in Python 2.X, with some minor bugs.
Then I tried to create an .exe file using py2exe. I prepared a setup.py file copying the source I found at pygame2exe wiki (http://www.pygame.org/wiki/Pygame2exe?parent=CookBook) also trying to use the suggestions I found in other questions here and in python-forum. What I obtained was the following error:
C:\Python34>python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in
origIsSystemDLL = py2exe.build_exe.isSystemDLL # save the orginal before we edit it
AttributeError: 'module' object has no attribute 'build_exe'
I have read all other posts on stackoverflow on pygame and exe but I haven’t found anything on this type of error on the web, is there anybody that can help me?
PS for those who prefer cx_freeze, I have tried it too, finding different problems and I will prepare soon another question on it
To give you more details, I am adding this new lines:
if I use the standard setup.py file instead, I have a dist directory with an .exe, but if I launch it I get an error window and in the log I find:
Traceback (most recent call last):
File "C:\Python34\lib\tokenize.py",
line 369, in find_cookie
line_string = line.decode('utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid start byte
During handling of the above exception, another exception occurred: etc....
And the first lines in the cmd are about 16 missing modules
if I try to use Python 2.6 instead of 3.4 I otain a Microsoft Visual C++ runtime error with the pygame2exe version, and a similar comment in the log if I use the 'short' py2exe version (Traceback (most recent call last):
File "Nomi_Animali_1.1p.py", line 100, in
basicFont = pygame.font.SysFont("FreeSansBold.ttf", 72)
File "pygame__init__.pyc", line 70, in getattr
NotImplementedError: font module not available
(ImportError: DLL load failed: Impossibile trovare il modulo specificato.))
I have tried in all cases to use as font: None, "Arial", "FreeSansBold.ttf"

Just import py2exe.build_exe again will work
>>> import py2exe
>>> py2exe.build_exe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'build_exe'
>>> import py2exe.build_exe
>>> py2exe.build_exe
<module 'py2exe.build_exe' from 'C:\\Python34\\lib\\site-packages\\py2exe\\build_exe.py'>

Related

Installed script with tkinter module returns error

I tried to convert my tkinter.py script to the tkinter.exe file. I used PyInstaller and I am sure the command was right, so no questions about PyInstaller. When conversion had completed I tried to execute but get the error:
Traceback (most recent call last):
File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth__tkinter.py", line 25, in <module>
FileNotFoundError: Tcl data directory "C:\Users\sashk\AppData\Local\Temp\_MEI42002\tcl" not found.
This error is related to tkinter module exactly and I can't find any solutions on the Web, please help.
I've renamed to Demo.py and it's started to work.

enable BUILD_PYTHON in CMake

I was trying to use Openpose from windows using https://github.com/CMU-Perceptual-Computing-Lab/openpose. But while I run a .py file it returned an error message
Error: OpenPose library could not be found. Did you enable `BUILD_PYTHON` in CMake and have this Python script in the right folder?
No module named 'pyopenpose'
An exception has occurred, use %tb to see the full traceback.
Traceback (most recent call last):
File "C:\Users\Santanu\Desktop\openpose\python\01_body_from_image.py", line 19, in <module>
raise e
File "C:\Users\Santanu\Desktop\openpose\python\01_body_from_image.py", line 16, in <module>
import pyopenpose as op
ModuleNotFoundError: No module named 'pyopenpose'
During handling of the above exception, another exception occurred:
SystemExit: -1
It has suggested from the error text to enable 'BUILD_PYTHON' in CMake and also said here. But I have never used CMake before. How to enable 'BUILD_PYTHON' in CMake?

autosklearn installation. Error: No module named 'sklearn.metrics.classification'

I'm trying to execute a script that uses Scikit and autosklearn on Ubuntu 20, python 3.8
I have followed the instructions to install sckit https://scikit-learn.org/stable/install.html and autosklearn installation https://automl.github.io/auto-sklearn/master/installation.html
However I'm getting
Exception ignored in: <function AutoML.__del__ at 0x7f37c6ee9160>
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/autosklearn/automl.py", line 1380, in __del__
self._backend.context.delete_directories(force=False)
AttributeError: 'AutoMLClassifier' object has no attribute '_backend'
Traceback (most recent call last):
File "myscript.py", line 261, in <module>
import model_snow_magn_only_package
File "/myfolder/myscript.py", line 150, in <module>
clf = pickle.load(open(model_name, "rb"))
ModuleNotFoundError: No module named 'sklearn.metrics.classification'
I have tried other releases of these packages but without success.
Does anyone have an idea of which releases/packages to install to make it work?

ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None

C:\Users\meela\Anaconda3\python.exe E:/TTIGAN/test.py
You can find the C code in this temporary file: C:\Users\meela\AppData\Local\Temp\theano_compilation_error_zncbj7_k
Traceback (most recent call last):
File "C:\Users\meela\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py", line 81, in <module>
actual_version, force_compile, _need_reload))
ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\meela\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py", line 105, in <module>
actual_version, force_compile, _need_reload))
ImportError: Version check of the existing lazylinker compiled file. Looking for version 0.211, but found None. Extra debug information: force_compile=False, _need_reload=True
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:/TTIGAN/test.py", line 1, in <module>
import skipthoughts
File "E:\TTIGAN\skipthoughts.py", line 6, in <module>
import theano
File "C:\Users\meela\Anaconda3\lib\site-packages\theano\__init__.py", line 110, in <module>
from theano.compile import (
File "C:\Users\meela\Anaconda3\lib\site-packages\theano\compile\__init__.py", line 12, in <module>
from theano.compile.mode import *
File "C:\Users\meela\Anaconda3\lib\site-packages\theano\compile\mode.py", line 11, in <module>
import theano.gof.vm
File "C:\Users\meela\Anaconda3\lib\site-packages\theano\gof\vm.py", line 674, in <module>
from . import lazylinker_c
File "C:\Users\meela\Anaconda3\lib\site-packages\theano\gof\lazylinker_c.py", line 140, in <module>
preargs=args)
File "C:\Users\meela\Anaconda3\lib\site-packages\theano\gof\cmodule.py", line 2388, in compile_str
(status, compile_stderr.replace('\n', '. ')))
.
Process finished with exit code 1
Same problem here, solved by installing a mingw-w64 import library for python(on Windows via conda) in your CLI type:
conda install -c anaconda libpython
I had the same problem, got me 2 days to resolve!
It was from path environment, i had another mingw path imported in variables and i removed it!
I had the same issue on my Mac. Installing theano via pip should fix this issue.
pip install theano
I had the same problem, it was caused by an old version of anaconda from 2014 that I forgot I even had. Just renaming the old directory fixed the problem.
The solution that worked for me was to uninstall my MinGW gcc compiler and reinstall the latest one. Make sure to restart your CLI before testing it.

How to convert HTML to PDF with python3

How to convert HTML to PDF with python3? i write some code about webView with pyqt5,and i want to convert the html in the webView to pdf,what should i do?
i have tried to use the html2pdf,but it seem to only support python2.x
and i have tried to install the wkhtmltox-0.12.2.2_msvc2013-win64.exe and pdfkit,and then use the example code.
import pdfkit
pdfkit.from_url('http://google.com', 'out.pdf')
pdfkit.from_file('test.html', 'out.pdf')
pdfkit.from_string('Hello!', 'out.pdf')
but i also failed.and the error is following.
Traceback (most recent call last):
File "E:\Python34\lib\site-packages\pdfkit\configuration.py", line 21, in __init__
with open(self.wkhtmltopdf) as f:
FileNotFoundError: [Errno 2] No such file or directory: b''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
pdfkit.from_url('http://google.com', 'out.pdf')
File "E:\Python34\lib\site-packages\pdfkit\api.py", line 22, in from_url
configuration=configuration)
File "E:\Python34\lib\site-packages\pdfkit\pdfkit.py", line 38, in __init__
self.configuration = (Configuration() if configuration is None
File "E:\Python34\lib\site-packages\pdfkit\configuration.py", line 27, in __init__
'https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf' % self.wkhtmltopdf)
OSError: No wkhtmltopdf executable found: "b''"
If this file exists please check that this process can read it. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
but i also failed.so what should i do? My system is window7 x64 ,python's version is 3.4
Since this hasn't had an accepted answer yet, there is a great library that works in Python 3 that I found after much searching and failed attempts at using PyPDF2, wkhtmltopdf beta branch for Python 3, qpdf, etc. It is weasyprint. I have the related answer and sample code here.
For completeness sake, from the documentation:
from weasyprint import HTML
HTML('http://weasyprint.org/').write_pdf('/tmp/weasyprint-website.pdf')
and it really works that easy.
'set path' probably means add **.exe to the system environment variable $Path$. For example, add D:\Program Files\wkhtmltopdf\bin to $Path$.

Resources