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"])
Related
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/*.*'
I have a project in Python 3.4 and GTK+ 3. I'm on Windows XP SP3 32-bit (VirtualBox).
I need to compile down to an executable using py2exe. (Do NOT suggest cx_freeze. It has ten times the problems on this project than py2exe).
My setup.py is as follows.
#!/usr/bin/python
from setuptools import setup
import py2exe
setup(name="Redstring",
version="2.0",
description="REDundant STRING generator",
author="MousePaw Labs",
url="http://www.mousepawgames.com/",
maintainer_email="info#mousepawgames.com",
data_files=[("", ["redstring.png", "redstring_interface.glade"])],
py_modules=["redstring"],
windows=[{'script':'redstring.py'}],
options={"py2exe":{
"unbuffered": True,
"compressed":True,
"bundle_files": 1,
'packages':['gi.repository'],
}},
zipfile=None
)
When I run it via C:\Documents and Settings\Jason\Desktop\redstring2>python setup.py py2exe, I get the following output (in full).
running py2exe
running build_py
1 missing Modules
------------------
? gi.repository.Gtk imported from __SCRIPT__
Building 'dist\redstring.exe'.
C:\Documents and Settings\Jason\Desktop\redstring2>
The actual script, redstring.py, runs without a hitch in my Windows environment. In that, I have the following (working) line of code: from gi.repository import Gtk That is ALL I import from gi.repository in the entire project.
If I swap the line in setup.py to 'packages':['gi'],, the error output switches to about 24-some-odd missing modules, all of them belonging to gi.repository. If I try and import "Gtk" or "gi.repository.Gtk" in either 'packages': or 'includes':, I get an error that the file in question being imported cannot be found.
I spent eight hours on #python (IRC channel) today, and no one could solve this. I need this packaged down to a Windows binary this week.
NOTE: This question is not a duplicate; while it is a similar issue, it is a) not the same error message, and b) neither answer solves the question in any way.
I solved this by, first of all, downgrading to Python 2.7. (GTK+ 3.8 is still fine.) py2exe apparently has known issues with Python 3.
Second, I switched...
options={"py2exe": {
"bundle_files": 1,
}
to
options={"py2exe": {
"bundle_files": 3,
}
For some reason, py2exe cannot include certain files needed to run the gi library when 'bundle_files' is set to 1 or 2.
The full setup.py that works with py2exe for my project can be found on GitHub. I run it on cmd with python setup.py py2exe.
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.
My script file test.py is:
try:
from visa import *
except Exception as ex:
print ex
raw_input()
My setup.py file is:
from distutils.core import setup
import py2exe
setup(console=['test.py'])
I then run:
python setup.py py2exe
If I then launch test.exe on my pc I see no issues but if I copy it to a new pc with no prior python installs I get:
[Error 126] The specified module could not be found
I don't know how to get the full traceback to print. Has anyone else seen this issue?
Running Python 2.7, PyVisa 1.4. Both machines are Win7.
Turns out the problem was that the visa libraries that pyvisa relies on weren't installed on the test pc. These libraries don't come included with pyvisa.
I have a problem with making exe using py2exe. In my project i'm using sqlalchemy with mssql module.
My setup.py script looks like:
from distutils.core import setup
import py2exe
setup(
windows=[{"script" : "pyrmsutil.py"}],
options={"pyrmsutil" : {
"includes": ["sqlalchemy.dialects.mssql", "sqlalchemy"],
"packages": ["sqlalchemy.databases.mssql", "sqlalchemy.cresultproxy"]
}})
But when i'm starting procedure like:
python.exe setup.py py2exe
I'm receiving build log with following errors:
The following modules appear to be missing
['_scproxy', 'pkg_resources', 'sqlalchemy.cprocessors', 'sqlalchemy.cresultproxy']
And in "dist" folder i see my pyrmsutil.exe file, but when i'm running it nothing happens. I mean that executable file starts, but do nothing and ends immediately without any pyrmsutil.exe.log. It's very strange.
Can anybody help me with this error?
I know it's no an answer per se but have you tries pyInstaller? I used to use py2exe and found it tricky to get something truly distributable. pyInstaller requires a little more setup but the docs are good and the result seems better.
For solving this issue you could try searching for the mentioned dlls and placing them in the folder with the exe, or where you build it.
Looks like py2exe can't find sqlalchemy c extensions.
Why not just include the egg in the distribution, put sqlachemy in py2exe's excludes and load the egg on start?
I use this in the start script:
import sys
import path
import pkg_resources
APP_HOME = path.path(sys.executable).parent
SUPPORT = APP_HOME / 'support'
eggs = [egg for egg in SUPPORT.files('*.egg')]
reqs, errs = pkg_resources.working_set.find_plugins(
pkg_resources.Environment(eggs)
)
map(pkg_resources.working_set.add, reqs)
sys.path.extend(SUPPORT.files('*.egg'))
i use Jason Orendorff's path module (http://pypi.python.org/pypi/path.py) but you can easily wipe it out if you want.