I am trying to learn Python by myself using Zed A.Shaw’s book Learn Python the hard way.
At exercise 46. I’am supposed to create a project skeleton (i.e. create a setup.py file, create modules, and so). Then make a project.
I have to put a script in my bin directory that is runnable for my system. I wrote the simple Hello World! script turned it into an .exe file using cxfreeze.
However when I try to install my setup.py file (i.e. By typing python setup.py install in the cmd), I can’t install this .exe file instead I can only install the script script.py
How can I install this exe file.
This is my setup.py file:
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
config = {
'description': 'First project',#ex46
'author': 'author',#
'url': '',#N/A
'download_url': '',#N/A
"author_email": "author_email@email.com"
'versio': '3.1',
'install_requires': ['nose'],
'packages': ['skeleton\quiz46','skeleton\\tests'],
'scripts': ['skeleton\\bin\helloscript.py','skeleton\\bin\helloscript.exe'],
'name': 'quiz46'
}
But this gives me the following error:
UnicodeDecodeError
I have also tried putting skeleton\bin\helloscript.exe but that gives me a similiar Error!
My OS is Windows 7, and I am using Python 3.1.
Again what I want is for the setup.py to install my .exe file too not just it’s script.
I don’t think the
scriptoption is meant to handle anything but text files. If you have a look at the source code for distribute (aka setuptools), thewrite_scriptcommand will try toencode('ascii')the contents if it’s anything other than a python script AND if you are using Python 3. Yourcxfreezeexe is a binary file, not a text file, and is likely causing this to choke.The easier option to get
setuptoolsto include a executable script in the installation process is to use theentry_pointsoption in yoursetup.pyrather thanscripts:The
console_scriptwill automatically wrap your originalhelloscript.pyscript and create anexe(on Windows) and install it into your Python’sScriptdirectory. No need to use something likecxfreeze.