so I've created a virtual environment in my iterm2 window. this is the ques I asked earlier which has not been solved yet and my app is not running is alias modeso i tried to do the whole process again but it was showing error with plistlib so that was fixed by this answer I tried this whole process again which means I did this all this before but my app was not working so i deleted my py2app and some venv's got deleted to I downloaded miniconda3 again and then it was working until it comes to running the app even in alias mode . but I continued and deleted the dist and build and when I executed
python setup.py py2app but then i got this error
Traceback (most recent call last):
File "setup.py", line 18, in <module>
setup_requires=['py2app'],
File "/Users/divyabansal/divya/lib/python3.7/site-packages/setuptools/__init__.py", line
145, in setup
return distutils.core.setup(**attrs)
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/dist.py", line 966, in
run_commands
self.run_command(cmd)
File "/Users/divyabansal/miniconda3/lib/python3.7/distutils/dist.py", line 985, in
run_command
cmd_obj.run()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 756,
in run
self._run()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 966,
in _run
self.run_normal()
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 1074,
in run_normal
self.create_binaries(py_files, pkgdirs, extensions, loader_files)
File "/Users/divyabansal/divya/lib/python3.7/site-packages/py2app/build_app.py", line 1384,
in create_binaries
mm.mm.run_file(runtime)
File "/Users/divyabansal/divya/lib/python3.7/site-packages/macholib/MachOGraph.py", line 89,
in run_file
raise ValueError("%r does not exist" % (pathname,))
ValueError: '/Users/divyabansal/miniconda3/lib/libpython3.7.dylib'
does not exist
please help me with this problem
Thank You!
This problem can often be fixed by creating a symlink, see here for more.
ln -s /path/to/lib/libpython3.7m.dylib /path/to/lib/libpython3.7.dylib
For the above command replace it with your own path.
Related
I am trying to create an executable for a script I have already written. It will be used by a coworker who doesn't have python on their machine, so I want to create an executable to make their life easier. I'm currently just trying to get py2exe to work and create an executable for a simple script that simply prints hello world and the constant e from the math module (just to get an idea for how py2exe works).
My setup script is as follows:
from distutils.core import setup
import py2exe
import math
setup(
console=[{'script':'hello.py'}],
options={
'py2exe':{
'packages' : ['math'],
'bundle_files':1
},
},
version='1.0.0'
)
where hello.py is simply:
import math
print('hello world!')
print(f'Here is e: {math.exp(1)}')
The error comes from this stack after I call "python setup.py py2exe" in cmd
Traceback (most recent call last):
File ".\setup.py", line 5, in <module>
setup(
File ".\Anaconda3\lib\site-packages\setuptools\_distutils\core.py", line 148, in setup
return run_commands(dist)
File ".\Anaconda3\lib\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
dist.run_commands()
File ".\Anaconda3\lib\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
self.run_command(cmd)
File ".\Anaconda3\lib\site-packages\setuptools\dist.py", line 1214, in run_command
super().run_command(command)
File ".\Anaconda3\lib\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
cmd_obj.run()
File ".\Anaconda3\lib\site-packages\py2exe\distutils_buildexe.py", line 192, in run
self._run()
File ".\Anaconda3\lib\site-packages\py2exe\distutils_buildexe.py", line 273, in _run
builder.build()
File ".\Anaconda3\lib\site-packages\py2exe\runtime.py", line 250, in build
self.build_archive(exe_path)
File ".\Anaconda3\lib\site-packages\py2exe\runtime.py", line 490, in build_archive
base = dist_path.rsplit('\\', 1)[0]
AttributeError: 'NoneType' object has no attribute 'rsplit'
To covert a .py file to .exe you need to install auto-py-to-exe
Windows
pip install auto-py-to-exe
After it is installed, open cmd then type
auto-py-to-exe
Then specify the path of the script and the location where you want to save the .exe file.
I'm attempting to use Py2exe to create a Python executable out of my program. The program definitely works and I've made sure all the libraries it uses are up to date, but when I attempt to run the command "python setup.py py2exe" to finish it up, I get an error I'm unfamiliar with.
The full output is below:
running py2exe
C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\site-packages\setuptools\distutils_patch.py:25: UserWarning: Distutils was imported before Setuptools. This usage is discouraged and may exhibit undesirable behaviors or errors. Please use Setuptools' objects directly or at least import Setuptools first.
warnings.warn(
Traceback (most recent call last):
File "C:\Users\user\OneDrive\Desktop\intern\pdf\setup.py", line 11, in
setup(console=[{ "script": "tca_script.py"}],
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1264.0_x64__qbz5n2kfra8p0\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\distutils_buildexe.py", line 192, in run
self._run()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\distutils_buildexe.py", line 272, in _run
builder.analyze()
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\runtime.py", line 172, in analyze
mf.import_package(modname)
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 84, in import_package
self.import_package("%s.%s" % (name, modname))
File "C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\py2exe\mf34.py", line 71, in import_package
package = self.modules[name]
KeyError: 'pandas.tests.io.excel'
Any help would be greatly appreciated.
I met the question about making .py into .exe. When I try using cx_freeze to pack, I will always get 'MSIError', which is something like this:
Traceback (most recent call last):
File "setup.py", line 15, in <module>
setup(name="NumberCounter",version="1.0",description="无",options={"build_exe":build_options},executables=executables)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
distutils.core.setup(**attrs)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\site-packages\cx_Freeze\windist.py", line 392, in run
self.add_files()
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\site-packages\cx_Freeze\windist.py", line 133, in add_files
cab.commit(db)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\msilib\__init__.py", line 220, in commit
add_stream(db, self.name, filename)
File "C:\Users\apple1\AppData\Local\Programs\Python\Python35\lib\msilib\__init__.py", line 129, in add_stream
r.SetStream(1, path)
_msi.MSIError: 1: 1101 2: C:\Users\apple1\AppData\Local\Temp\tmp5kgryuh8 3: 2
How can I solve it and why did it happen?
I'll unpack the error line for you.
_msi.MSIError: 1: 1101 2: C:\Users\apple1\AppData\Local\Temp\tmp5kgryuh8 3: 2
Per Windows Installer Error Messages, 1101 means Could not open file stream: [2]. System error: [3].
Per command net helpmsg 2, system error 2 is The system cannot find the file specified.
The path appears to be a temporary file that should have been created, but according to the error, it probably was not. You could try to use a tool like Process Monitor to figure out what if anything is going on with the temporary files.
I don't know anything useful about cx_freeze, but I do know that Windows Installer's support for Unicode is a little surprising; it can easily come off as half-baked. Because of that, I would worry about your description="无", and consider setting that to a simple ASCII-only string, just to see if it helps.
I have a .py file that creates a GUI, which runs another script once I give it some information. I'm trying to make a .exe file from this GUI file using py2exe, but I've been having trouble.
Exception: Seems not to be an exe-file
If anyone who has experience with py2exe and has encountered this message before, could you explain to me why it's not working, and what I could do to fix it? Thanks in advance.
EDIT: My setup.py looks like this:
from distutils.core import setup
import py2exe
setup(console=['test_gui.py'])
I run this code through the command prompt like this:
python setup.py py2exe
And the traceback is as follows:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
setup(console=['test_gui.py'])
File "C:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 243, in run
self._run()
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 305, in _run
dlls = self.find_dlls(extensions)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 389, in find_dlls
self.dll_excludes)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1064, in find_d
ependend_dlls
bin_depends(loadpath, images + [sys.executable], excludes_use)
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1441, in bin_de
pends
if isSystemDLL(dll):
File "C:\Python26\Lib\site-packages\py2exe\build_exe.py", line 1498, in isSyst
emDLL
raise Exception, "Seems not to be an exe-file"
Exception: Seems not to be an exe-file
I'm trying to build an application with py2app using a virtual python environment. I have python 2.7.3. I can build the app fine using python 2.6 (which I have py2app on), but not with my 2.7.3 virtualenv (because I can't install py2app in my 2.7.3 system-wide installation).
This is the error I get:
running py2app
creating /Users/student/Desktop/Coding Projects/MCManager/build/bdist.macosx-10.6-intel/python2.7-standalone/app
creating /Users/student/Desktop/Coding Projects/MCManager/build/bdist.macosx-10.6-intel/python2.7-standalone/app/collect
creating /Users/student/Desktop/Coding Projects/MCManager/build/bdist.macosx-10.6-intel/python2.7-standalone/app/temp
creating build/bdist.macosx-10.6-intel/python2.7-standalone/app/lib-dynload
creating build/bdist.macosx-10.6-intel/python2.7-standalone/app/Frameworks
Traceback (most recent call last):
File "AppSpec.py", line 21, in <module>
app = ['ScriptUnix.py']
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/Users/student/Desktop/VE/MyVirtEnv/lib/python2.7/site-packages/py2app/build_app.py", line 520, in run
self._run()
File "/Users/student/Desktop/VE/MyVirtEnv/lib/python2.7/site-packages/py2app/build_app.py", line 708, in _run
self.run_normal()
File "/Users/student/Desktop/VE/MyVirtEnv/lib/python2.7/site-packages/py2app/build_app.py", line 779, in run_normal
mf = self.get_modulefinder()
File "/Users/student/Desktop/VE/MyVirtEnv/lib/python2.7/site-packages/py2app/build_app.py", line 658, in get_modulefinder
debug=debug,
File "/Users/student/Desktop/VE/MyVirtEnv/lib/python2.7/site-packages/modulegraph/find_modules.py", line 271, in find_modules
find_needed_modules(mf, scripts, includes, packages)
File "/Users/student/Desktop/VE/MyVirtEnv/lib/python2.7/site-packages/modulegraph/find_modules.py", line 196, in find_needed_modules
path = m.packagepath[0]
TypeError: 'NoneType' object has no attribute '__getitem__'
I'm in the directory of the py2app setup file, running it with ~/Desktop/VE/MyVirtEnv/bin/python AppSpec.py py2app. If I run the same thing with python26 AppSpec.py py2app, it works fine.