I was building apps in Python on a Mac. it was upgrading. I upgraded and now the program crashes in setup.py.
The code that I use is
"""
This is a setup.py script generated by py2applet
Usage:
python3 setup.py py2app -A
for this must do rm -rf dist build
To install a missing package "pip3 install MODULENAME"
or
python3 setup.py py2app for final App
or
/usr/local/bin/python3.10 setup.py py2app
"""
from setuptools import setup
APP = ['Analyze pH.py']
DATA_FILES = []
OPTIONS = {'iconfile': 'SVA.icns',
'argv_emulation': True}
setup(
app=APP,
version='3.5',
author='Howard Matis',
author_email='Howard#svadvantage.com',
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app']
)
When I run "usr/local/bin/python3.10 setup.py py2app" I get:
running py2app
creating /Users/matis/Library/Mobile Documents/com~apple~CloudDocs/Silicon Valley Advant/SensTek/pH Analysis/Analyze pH Files - V3.5/build/bdist.macosx-10.9-universal2/python3.10-standalone/app
creating /Users/matis/Library/Mobile Documents/com~apple~CloudDocs/Silicon Valley Advant/SensTek/pH Analysis/Analyze pH Files - V3.5/build/bdist.macosx-10.9-universal2/python3.10-standalone/app/collect
creating /Users/matis/Library/Mobile Documents/com~apple~CloudDocs/Silicon Valley Advant/SensTek/pH Analysis/Analyze pH Files - V3.5/build/bdist.macosx-10.9-universal2/python3.10-standalone/app/temp
creating build/bdist.macosx-10.9-universal2/python3.10-standalone/app/lib-dynload
creating build/bdist.macosx-10.9-universal2/python3.10-standalone/app/Frameworks
Traceback (most recent call last):
File "/Users/matis/Library/Mobile Documents/com~apple~CloudDocs/Silicon Valley Advant/SensTek/pH Analysis/Analyze pH Files - V3.5/setup.py", line 22, in <module>
setup(
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 145, in setup
return distutils.core.setup(**attrs)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/core.py", line 148, in setup
dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/distutils/dist.py", line 966, in run_commands
,,,
q = self._import_module(head, qname, parent)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/modulegraph/modulegraph.py", line 1421, in _import_module
m = self._load_module(fqname, fp, pathname, stuff)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/modulegraph/modulegraph.py", line 1512, in _load_module
self._scan_code(co, m)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/modulegraph/modulegraph.py", line 1719, in _scan_code
self._scan_bytecode_stores(compile(co, "-", "exec", 0, True), m)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/modulegraph/modulegraph.py", line 1752, in _scan_bytecode_stores
for inst in dis.get_instructions(co):
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/dis.py", line 288, in get_instructions
line_offset)
UnboundLocalError: local variable 'line_offset' referenced before assignment
Help. I cannot figure out what is the problem. I am doing this on a PowerMac V 12.1.
Related
I am trying to upgrade pip and keep getting this message:
You are using pip version 10.0.1, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(base) name-MBP:~ name$ pip3 install --upgrade pip
Exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/basecommand.py", line 228, in main
status = self.run(options, args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 244, in run
wheel_cache = WheelCache(options.cache_dir, options.format_control)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/cache.py", line 186, in __init__
self._ephem_cache = EphemWheelCache(format_control)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/cache.py", line 164, in __init__
self._temp_dir.create()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/utils/temp_dir.py", line 73, in create
tempfile.mkdtemp(prefix="pip-{}-".format(self.kind))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tempfile.py", line 356, in mkdtemp
prefix, suffix, dir, output_type = _sanitize_params(prefix, suffix, dir)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tempfile.py", line 126, in _sanitize_params
dir = gettempdir()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tempfile.py", line 294, in gettempdir
tempdir = _get_default_tempdir()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tempfile.py", line 229, in _get_default_tempdir
dirlist)
FileNotFoundError: [Errno 2] No usable temporary directory found in ['/var/folders/40/vdlxclg51vjf1q5y8ygtbb840000gn/T/', '/tmp', '/var/tmp', '/usr/tmp', '/Users/name']
Even when I am un/installing any thirty party packages (e.g. numpy) i am getting this exception.
I do have a cx_freeze issue on python 3.7.6.4 ond Windows 10 (also tried Windows 7 - same error) - using this makeexe:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os", "sys"],
"include_files": ["DMCA.ico"]
}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "DMCA",
version = "0.01",
description = "DMCA by EP",
options = {"build_exe": build_exe_options},
executables = [Executable("DMCA.py", base=base, icon="DMCA.ico")])
I do get:
C:\WPy64-3760\Code\09Working>makeexe
C:\WPy64-3760\Code\09Working>C:/WPy64-3760/python-3.7.6.amd64/python MakeExe.py build
running build
running build_exe
copying C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\bases\Win32GUI.exe -> build\exe.win-amd64-3.7\DMCA.exe
copying C:\WPy64-3760\python-3.7.6.amd64\python37.dll -> build\exe.win-amd64-3.7\python37.dll
copying C:\WPy64-3760\python-3.7.6.amd64\VCRUNTIME140.dll -> build\exe.win-amd64-3.7\VCRUNTIME140.dll
error: [WinError 2] Das System kann die angegebene Datei nicht finden: 'build\\exe.win-amd64-3.7\\DMCA.exe'
and if I use:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["os", "sys"]}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "DMCA",
version = "0.01",
description = "DMCA by EP",
options = {"build_exe": build_exe_options},
executables = [Executable("DMCA.py", base=base)])
The error is:
C:\WPy64-3760\Code\09Working>makeexe
C:\WPy64-3760\Code\09Working>C:/WPy64-3760/python-3.7.6.amd64/python MakeExe.py build
running build
running build_exe
copying C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\bases\Win32GUI.exe -> build\exe.win-amd64-3.7\DMCA.exe
copying C:\WPy64-3760\python-3.7.6.amd64\python37.dll -> build\exe.win-amd64-3.7\python37.dll
copying C:\WPy64-3760\python-3.7.6.amd64\VCRUNTIME140.dll -> build\exe.win-amd64-3.7\VCRUNTIME140.dll
Traceback (most recent call last):
File "MakeExe.py", line 21, in <module>
executables = [Executable("DMCA.py", base=base)])
File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\dist.py", line 348, in setup
distutils.core.setup(**attrs)
File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\WPy64-3760\python-3.7.6.amd64\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\freezer.py", line 617, in Freeze
self._FreezeExecutable(executable)
File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\freezer.py", line 208, in _FreezeExecutable
self._AddVersionResource(exe)
File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\cx_Freeze\freezer.py", line 143, in _AddVersionResource
stamp(fileName, versionInfo)
File "C:\WPy64-3760\python-3.7.6.amd64\lib\site-packages\win32\lib\win32verstamp.py", line 163, in stamp
h = BeginUpdateResource(pathname, 0)
pywintypes.error: (2, 'BeginUpdateResource', The system cannot find the file specified.)
how can I find the problem?
The source code, which I want to freeze is larger; PyQt QmainWindow and multiple sub-files using matplotlib 3.2.1, pillow 6.2.1, scipy 1.4.1 and numpy 1.17.4+mkl, so it would overwhelm this page. I also tried to add my sub-files to build_exe_options as 'includes' and output is the same.
Setup new Python and installing the packages solved this issue, nevertheless the executable is not working properly. Closing this issue.
In my python project, I have this hierarchy
+ slack_app
+ src
+ apps
+ intro
+ \__main__.py
+ slack_app.py
+ setup.py
This is my setup.py:
setup(
name= "my-slack-app",
packages = find_packages(),
entry_points = {
'console_scripts': [
'slack-app = src.apps.intro.__main__:main',
],
})
__main__.py:
def main():
print("WORKED")
if __name__ == "__main__":
main()
I run python3 setup.py install, then run my app which is installed in /usr/local/python3.6/bin but I always get this error when I run it:
Traceback (most recent call last):
File "/usr/local/python3.6/bin/slack-app", line 11, in <module>
load_entry_point('my-slack-app==0.1.dev2+g4fd21b0.d20200309',
'console_scripts', 'slack-app')()
File "/usr/local/python3.6/lib/python3.6/site-
packages/pkg_resources/__init__.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/python3.6/lib/python3.6/site-
packages/pkg_resources/__init__.py", line 2854, in
load_entry_point
return ep.load()
File "/usr/local/python3.6/lib/python3.6/site-
packages/pkg_resources/__init__.py", line 2445, in load
return self.resolve()
File "/usr/local/python3.6/lib/python3.6/site-
packages/pkg_resources/__init__.py", line 2451, in resolve
module = __import__(self.module_name, fromlist=['__name__'],
level=0)
ModuleNotFoundError: No module named 'src.apps'
Any help please?
If you are using setuptools.find_packages, then you need to have __init__.py files. Also you are using the so-called src-layout so you need to adjust the package_dir and set the where parameter of find_packages.
Reference:
https://setuptools.readthedocs.io/en/latest/setuptools.html#using-find-packages
when I try to compile program in python 3.7
with:
auto-py-to-exe v2.6.0
Selenium
The code is:
from selenium import webdriver
import pathlib
import resource
fn = pathlib.Path(__file__).parent / 'chromedriver.exe'
browser = webdriver.Chrome(fn)
browser.get('website')
# fill in username and hit the next button
username = browser.find_element_by_id('user_login')
username.send_keys('xxxxxxx')
password = browser.find_element_by_id('user_pass')
password.send_keys('xxxxxxxxxx')
nextButton1 = browser.find_element_by_id('wp-submit')
nextButton1.click()
browser.get('website')
nextButton2 = browser.find_element_by_class_name('add-new-h2')
nextButton2.click()
nextButton3 = browser.find_element_by_id('is_continue_no')
nextButton3.click()
nextButton4 = browser.find_element_by_class_name('rad10')
nextButton4.click()
error in compile
An error occurred, traceback follows:
Traceback (most recent call last):
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\auto_py_to_exe-2.6.0-py3.7.egg\auto_py_to_exe\__main__.py", line 259, in convert
pyi.run() # Execute PyInstaller
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\PyInstaller\__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\PyInstaller\building\build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 29, in <module>
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\PyInstaller\building\api.py", line 424, in __init__
strip_binaries=self.strip, upx_binaries=self.upx,
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\PyInstaller\building\api.py", line 196, in __init__
self.__postinit__()
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
self.assemble()
File "e:\documentos\proyectos\synctango2woocomerce\venv\lib\site-packages\PyInstaller\building\api.py", line 273, in assemble
pylib_name = os.path.basename(bindepend.get_python_library_path())
File "C:\Users\Jesus-NewPC\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 214, in basename
return split(p)[1]
File "C:\Users\Jesus-NewPC\AppData\Local\Programs\Python\Python37\lib\ntpath.py", line 183, in split
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
all log
i expect correct compile
i try
install windows sdk
install visual c++ libraries
need help to resolve the problem
this is the code from my python program
One problem with your code is that you are trying to load chromedriver.exe which can be found in your current directory but after freezing it cannot be loaded anymore. When you want to freeze your app with Pyinstaller you first need to add that file to your output executable and then load it from the temp directory.
I'm not sure about auto-py-to-exe but you can use the below code and then use
pyinstaller -F --add-data "chromedriver.exe;." yourscript.py
from selenium import webdriver
import resource
import sys
import os
def resource_path(relative_path):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath("."), relative_path)
fn = resource_path('chromedriver.exe')
browser = webdriver.Chrome(fn)
browser.get('website')
# fill in username and hit the next button
username = browser.find_element_by_id('user_login')
username.send_keys('xxxxxxx')
password = browser.find_element_by_id('user_pass')
password.send_keys('xxxxxxxxxx')
nextButton1 = browser.find_element_by_id('wp-submit')
nextButton1.click()
browser.get('website')
nextButton2 = browser.find_element_by_class_name('add-new-h2')
nextButton2.click()
nextButton3 = browser.find_element_by_id('is_continue_no')
nextButton3.click()
nextButton4 = browser.find_element_by_class_name('rad10')
nextButton4.click()
Solved in the simplest way, pass the proyect folder with the script to
disk C: and the errors were solved gave error while it was saved in disk E:
I'm having difficulty building my app using py2app. I can build it in alias mode without issue using this command:
python3.4 setup.py py2app -A
However when I try and build it using:
python3.4 setup.py py2app
I get the error message as per title of this post. From the research I've done I believe it's an issue with Pillow; however I need Pillow for this app. (Unless there's another module I can use to import images??). I've also tried cx_freeze without success.
Any help or direction much appreciated.
Full traceback as follows:
Traceback (most recent call last):
File "setup.py", line 19, in <module>
setup_requires=['py2app'],
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/core.py", line 148, in setup dist.run_commands()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/dist.py", line 955, in run_commands self.run_command(cmd)
File"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
distutils/dist.py", line 974, in run_command cmd_obj.run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 659, in run self._run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 865, in _run self.run_normal()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 959, in
run_normal self.create_binaries(py_files, pkgdirs, extensions,loader_files)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site- packages/py2app/build_app.py", line 1214, in create_binaries
platfiles = mm.run()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOStandalone.py", line 105, in run
mm.run_file(fn)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 84, in run_file
self.scan_node(m)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 110, in scan_node
m = self.load_file(filename, caller=node)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 93, in load_file
newname = self.locate(name, loader=caller)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOStandalone.py", line 23, in locate
newname = super(FilteredMachOGraph, self).locate(filename, loader)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/
site-packages/macholib/MachOGraph.py", line 49, in locate
loader=loader.filename)
TypeError: dyld_find() got an unexpected keyword argument 'loader'
This is a temporary solution, and it may break other things. I would recommend doing this is a virtual environment so you don't mess up your regular packages. This worked for me (virtenv is the name of my virtual environment)
Open the file /virtenv/lib/python3.4/site-packages/macholib/dyld.py and replace each instance of loader_path with loader. Now save and try again.
You can monkey-patch macholib rather than modifying it in site-packages. Place the following file to the directory containing setup_py2app.py and add import macholib_patch to the top.
macholib_patch.py:
"""
Monkey-patch macholib to fix "dyld_find() got an unexpected keyword argument 'loader'".
Add 'import macholib_patch' to the top of set_py2app.py
"""
import macholib
#print("~"*60 + "macholib verion: "+macholib.__version__)
if macholib.__version__ <= "1.7":
print("Applying macholib patch...")
import macholib.dyld
import macholib.MachOGraph
dyld_find_1_7 = macholib.dyld.dyld_find
def dyld_find(name, loader=None, **kwargs):
#print("~"*60 + "calling alternate dyld_find")
if loader is not None:
kwargs['loader_path'] = loader
return dyld_find_1_7(name, **kwargs)
macholib.MachOGraph.dyld_find = dyld_find