cx_Freeze: Python error in main script - python

I am a beginner in python and django. This error keeps coming, even after installing cx_freeze from http://www.lfd.uci.edu/~gohlke/pythonlibs/#cx_freeze
I am trying to make an executable file and I want to run my server through it, which I normally do by:
manage.py runserver
I am currently using commands:
setup.py build
I have already tried:
pyinstaller --name=mysite myproject_dir/manage.py
and my setup.py file contains
import sys
from distutils.core import setup
from cx_Freeze import setup, Executable
setup(
name = "Management System",
version = "1.0",
description = "A Database Management System",
py_modules=['virtualenv'],
executables = [Executable("manage.py", base = "Win32GUI")])
I have also tried py2exe, it doesn't work. You can also suggest to read something for this knowledge.
Here is the image of error that keeps appearing on running the exe file
If I use this command:
Barcode.exe runserver
There also comes an error
WindowsError: [Error 3] The system cannot find the path specified:'C:\\Users\\D ell\\AppData\\Local\\Temp\\_MEI85~1\\Entry\\migrations/*.*'

Related

Py2exe [Errno 2] No such file or directory: 'm'

I'm trying to use py2exe to create a simple exe using py2exe. Unfortunately, when I try to create even a simple py2exe, it fails.
My Python script is:
print("Hello World")
My setup script is:
from distutils.core import setup
import py2exe
setup(console="mouse-check.py")
When I run py py2exe-installer.py py2exe I get the following output:
C:\Users\...\Python\py2exe-installer.py:1: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.core import setup
running py2exe
error: [Errno 2] No such file or directory: 'm'
I'm using Python 3.10.4 on Windows.
My py2exe version is: 0.11.1.1
My directory structure is:
/Python
- py2exe-installer.py
- mouse-check.py
Anyone have any idea what "m" is referring to here?
The setup function requires console argument is list, you can read more details in the implementation. Or tutorial and examples here.
Your setup script should be looked like this
from distutils.core import setup
import py2exe
setup(console=["mouse-check.py"])

How to use cx_Freeze to make an executable python program

I downloaded cx_Freeze because I'm trying to make a .exe file to share with my platoon and I've been reading through the docs as well as scrolling through cx_Freeze tutorial. After following both of those I still don't know why this isn't working for me. I'm on Python 3.6.2 and I have the path directly setup to the command line.
I tried to launch with setup.py and Julian date 2.py on the desktop and I tried adding them to same folder, but no matter what I try I get back this error when I type python setup.py build, python: can't open file 'setup.py': [Error2] no such file or directory or file exsists. Below is my setup.py code.
from cx_Freeze import setup, Executable
setup(name = "Julian date 2" ,
version = "0.1" ,
description = "" ,
executables = [Executable("Julian date 2.py")])
Another issue I ran into was trying to type cxfreeze Julian date 2.py --target-dir dist I get the error 'cxfreeze' is not recognized as an internal or external command, operable program or batch file.
When you type python setup.py build, you are supposed to be in the directory with setup.py and not anywhere else. So use the command cd to get there.
cx_freeze is not in your path variable so cxfreeze Julian date 2.py --target-dir dist will not work and you have to instead add it to your path (somehow) [not recommended]
Hope this helped.
P.S.
executables = [Executable("Julian date 2.py")]) takes base too. If you want a console application:
executables = [Executable("Julian date 2.py",base='None')])
Gui for windows:
executables = [Executable("Julian date 2.py",base='Win32GUI')])
And you forgot your exe options in setup(). I recommend adapting the setup.py script on cx_freeze doxs:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"]}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = "None"
setup( name = "name",
version = "0.1",
description = " ",
options = {"build_exe": build_exe_options},
executables = [Executable("file.py", base=base)])
I solved the first issue, my file was named 'setup.py' and not just 'setup' as it's supposed to be...The name must be setup, the extension .py
Know it's DUMB, after hours, that was the problem...

Py2exe Error creating exe - Directory

So I'm just trying to create an exe from a simple hello world program using py2exe. I have created the setup file (setup.py) with the following code:
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
(I have also tried setup(console=[{"script":'hello.py'}]) as per another suggestion )
I run cmd as an administrator and type C:\python27\setup.py py2exe
It then says:
error: hello.py: No such file or directory
I have the hello.py file in the same folder as the setup file. Looked at many different forums and py2exe tutorials and none seem to have answers, any help would be greatly appreciated.
You have to first navigate to that directory and then make the python call:
C:>cd C:\python27
C:\python27>python setup.py py2exe
Note: your hello.py script should also be in C:\python27 directory.

Py2app keyflag error CFLAGS

What I'm trying to do is compile a program I've written in Python 2.7, using pygame, into a standalone app for Mac computers. I'm working on a PC running Windows 8 with no access to a mac, so tweaking the process has been difficult.
When I run the setup file from the command prompt, I get the "text flood" (similar to what py2exe gave me when it worked to compile the windows version) and the program appears to work. It creates build and dist folders, but the dist folder has no contents. When looking at the command prompt output, the last two lines are
BASE_CFLAGS = cfg['CFLAGS']
Key Error: 'CFLAGS'
This seems to happen when py2app is trying to create the application bundle.
Here is the setup.py file I've gotten to thus far:
"""
Script for building the example.
Usage:
python setup.py py2app
"""
from setuptools import setup
NAME = 'PetCute Slide Puzzle Test'
VERSION = '0'
plist = dict(
CFBundleIconFile=NAME,
CFBundleName=NAME,
CFBundleShortVersionString=VERSION,
CFBundleGetInfoString=' '.join([NAME, VERSION]),
CFBundleExecutable=NAME,
CFBundleIdentifier='Py2App and PyGam test',
)
setup(
data_files=['Dog1.jpg', 'Dog2.jpg', 'Dog3.jpg', 'Dog4.jpg', 'Dog5.jp', 'Dog6.jpg', 'Dog7.jpg', 'Dog8.jpg', 'Dog9.jpg', 'Dog10.jpg', 'Dog11.jpg', 'Dog12.jpg', 'Dog13.jpg', 'Dog14.jpg', 'Dog15.jpg', 'Dog16.jpg', 'AYearWithoutRain.ttf'],
app=[
dict(script="PetCute_slidepuzzle.py", plist=plist),
],
setup_requires=["py2app"],
)
The data_files lists out the pictures and text file that need to be bundled with the code. I got to this by adapting the alien.py example. Please let me know if any more info is needed!
It probably had an error during compilation. I suggest you make sure you have Numpy installed, its needed for py2app to compile Pygame programs.

Python: How to include the exe file of a script in setup.py

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 script option is meant to handle anything but text files. If you have a look at the source code for distribute (aka setuptools), the write_script command will try to encode('ascii') the contents if it's anything other than a python script AND if you are using Python 3. Your cxfreeze exe is a binary file, not a text file, and is likely causing this to choke.
The easier option to get setuptools to include a executable script in the installation process is to use the entry_points option in your setup.py rather than scripts:
entry_points={'console_scripts':['helloscript = helloscript:main'] }
The console_script will automatically wrap your original helloscript.py script and create an exe (on Windows) and install it into your Python's Script directory. No need to use something like cxfreeze.

Categories