I am trying to build a basic Python tkinter application I developed. When I try building the application with cx_freeze via the command prompt, I get the following error output:
C:\Users\RedCode\PycharmProjects\DatabaseExample>python setup.py build
running build
running build_exe
Traceback (most recent call last):
File "setup.py", line 26, in <module>
executables = [Executable("cardb.py", base = base)])
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\dist.py", line 349, in setup
distutils.core.setup(**attrs)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\distutils\command\build.py", line 135, in run
self.run_command(cmd_name)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\dist.py", line 219, in run
freezer.Freeze()
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\freezer.py", line 623, in Freeze
self._FreezeExecutable(executable)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\freezer.py", line 199, in _FreezeExecutable
finder.IncludeFile(exe.script, exe.moduleName)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 633, in IncludeFile
deferredImports)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 474, in _LoadModule
self._ScanCode(module.code, module, deferredImports)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 564, in _ScanCode
module, relativeImportIndex)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 310, in _ImportModule
deferredImports, namespace = namespace)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 403, in _InternalImportModule
parentModule, namespace)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 416, in _LoadModule
namespace)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 485, in _LoadPackage
self._LoadModule(name, fp, path, info, deferredImports, parent)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 463, in _LoadModule
self._RunHook("load", module.name, module)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\finder.py", line 536, in _RunHook
method(self, *args)
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cx_Freeze\hooks.py", line 613, in load_tkinter
tclSourceDir = os.environ["TCL_LIBRARY"]
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\lib\os.py", line 669, in __getitem__
raise KeyError(key) from None
KeyError: 'TCL_LIBRARY'
When I try using pyinstaller, I first tried pip install setup.pyand got the following output:
C:\Users\RedCode\PycharmProjects\DatabaseExample>pip install setup.py
Collecting setup.py
Downloading setup.py-0.1.0.tar.gz
Installing collected packages: setup.py
Running setup.py install for setup.py ... done
Successfully installed setup.py-0.1.0
Even though it says it was successful, I cannot find anything of it on my computer, even after using the search function on my entire machine.
I then tried pyinstaller setup.py and got the following output error:
C:\Users\RedCode\PycharmProjects\DatabaseExample>pyinstaller setup.py
495 INFO: PyInstaller: 3.2.1
495 INFO: Python: 3.6.1
496 INFO: Platform: Windows-10-10.0.10240-SP0
501 INFO: wrote C:\Users\RedCode\PycharmProjects\DatabaseExample\setup.spec
503 INFO: UPX is not available.
509 INFO: Extending PYTHONPATH with paths
['C:\\Users\\RedCode\\PycharmProjects\\DatabaseExample',
'C:\\Users\\RedCode\\PycharmProjects\\DatabaseExample']
509 INFO: checking Analysis
509 INFO: Building Analysis because out00-Analysis.toc is non existent
510 INFO: Initializing module dependency graph...
512 INFO: Initializing module graph hooks...
518 INFO: Analyzing base_library.zip ...
Traceback (most recent call last):
File "C:\Users\RedCode\AppData\Local\Programs\Python\Python36-32\Scripts\pyinstaller-script.py", line 11, in <module>
load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')()
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\__main__.py", line 90, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\__main__.py", line 46, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build
exec(text, spec_namespace)
File "<string>", line 16, in <module>
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\build_main.py", line 212, in __init__
self.__postinit__()
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\datastruct.py", line 161, in __postinit__
self.assemble()
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\building\build_main.py", line 317, in assemble
excludes=self.excludes, user_hook_dirs=self.hookspath)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\depend\analysis.py", line 560, in initialize_modgraph
graph.import_hook(m)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1509, in import_hook
source_package, target_module_partname, level)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1661, in _find_head_package
target_module_headname, target_package_name, source_package)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\depend\analysis.py", line 209, in _safe_import_module
module_basename, module_name, parent_package)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2077, in _safe_import_module
module_name, file_handle, pathname, metadata)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2167, in _load_module
self._scan_code(m, co, co_ast)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2585, in _scan_code
module, module_code_object, is_scanning_imports=False)
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2831, in _scan_bytecode
global_attr_name = get_operation_arg_name()
File "c:\users\RedCode\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2731, in get_operation_arg_name
return module_code_object.co_names[co_names_index]
IndexError: tuple index out of range
Here is the code of my setup file:
application_title = "Car Database"
main_python_file = "cardb.py"
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name = "cardb.py",
version = "0.1",
description = "Simple tkinter application",
executables = [Executable("cardb.py", base = base)])
I am using cx_Freeze to build the application, and I am running Python 3.6.1 via PyCharm-Community 2017.1.1 if that helps. I have searched everywhere and cannot seem to find anything that works (and it looks like the support for Python 3.6.x is very poor).
How can I build my application successfully? Or in the very least how can I correct these errors that occur during the build?
import sys
import os
from cx_Freeze import setup, Executable
import cx_Freeze
import tkinter
import os.path
base = None
if sys.platform == 'win32':
base = "Win32GUI"
PYTHON_INSTALL_DIR = os.path.dirname(os.path.dirname(os.__file__))
os.environ['TCL_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tcl8.6')
os.environ['TK_LIBRARY'] = os.path.join(PYTHON_INSTALL_DIR, 'tcl', 'tk8.6')
#This was another style I tried using. If you don't have your python installed #to your path you could try this method. Obviously need to update the URL to #those files
#os.environ['TCL_LIBRARY'] = r'C:\Users\gardener\Downloads\WinPython-64bit-3.5.3.0Qt5\python-3.5.3.amd64\tcl\tcl8.6'
#os.environ['TK_LIBRARY'] = r'C:\Users\gardener\Downloads\WinPython-64bit-3.5.3.0Qt5\python-3.5.3.amd64\tcl\tk8.6'
executables = [cx_Freeze.Executable("cardb.py", base=base)]
options = {
'build_exe': {
'include_files':[
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tk86t.dll'),
os.path.join(PYTHON_INSTALL_DIR, 'DLLs', 'tcl86t.dll'),
]
},
}
cx_Freeze.setup(
name = "cardb",
options = options,
version = "0.1",
description = 'Simple tkinter application',
executables = executables
)
Give that a try
Related
I've been trying to set up a virtual environment for django using pipenv. I've installed pipenv and configured the path properly. When I run the following command
pipenv --version
I get
pipenv, version 2022.9.8
Which implies that pipenv is working.
But when I attempt to install django with the following command
pipenv install django
I get the following error.
C:\Users\Saifia>pipenv install django
Traceback (most recent call last):
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 620, in parse_executable
result_version = get_python_version(path)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\utils.py", line 97, in get_python_version
c = subprocess.Popen(version_cmd, **subprocess_kwargs)
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts\pipenv.exe\__main__.py", line 7, in <module>
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\cli\options.py", line 57, in main
return super().main(*args, **kwargs, windows_expand_args=False)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1053, in main
rv = self.invoke(ctx)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\cli\command.py", line 236, in install
do_install(
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 2056, in do_install
ensure_project(
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 526, in ensure_project
ensure_virtualenv(
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 447, in ensure_virtualenv
python = ensure_python(project, three=three, python=python)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 336, in ensure_python
path_to_python = find_a_system_python(python)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\core.py", line 302, in find_a_system_python
return next(iter(finder.find_all_python_versions()), None)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 307, in find_all_python_versions
python_version_dict = getattr(self.system_path, "python_version_dict", {})
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 115, in system_path
self._system_path = self.create_system_path()
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 77, in create_system_path
return pyfinder_path.SystemPath.create(
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 696, in create
instance = instance._run_setup()
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 247, in _run_setup
new_instance = new_instance._setup_windows()
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 425, in _setup_windows
windows_finder = WindowsFinder.create()
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 149, in create
return cls()
File "<attrs generated init pythonfinder.models.windows.WindowsFinder>", line 13, in __init__
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 116, in get_versions
versions[py_version.version_tuple[:5]] = base_dir
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 367, in __getattribute__
result = super(PythonVersion, self).__getattribute__(key)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 432, in version_tuple
self.patch,
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 377, in __getattribute__
instance_dict = self.parse_executable(executable)
File "C:\Users\Saifia\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 622, in parse_executable
raise ValueError("Not a valid python path: %r" % path)
ValueError: Not a valid python path: 'C:/Users/Saifia/anaconda3/Scripts/python.exe'
I've been trying to figure this out the whole day and have tried various things but I'm new this and I can't figure out my mistake.
Any help will be greatly appreciated!
I was using virtualenv for virtualization and had to use pipenv to follow a tutorial and could not get pipenv to work. I had to uninstall virtualenv and pipenv and reinstall pipenv for it to work. I am still using pipenv but I do not like it virtualenv works better for me.
I think that the key to your problem is the last message in the traceback:
"ValueError: Not a valid python path: 'C:/Users/Saifia/anaconda3/Scripts/python.exe'"
Check and see if this file exists at this location.
If not, your default python version isn't set correctly in pipenv.
Deactivate any virtual environment and check your python version before you install pipenv.
C:\Users\pheelz\Desktop>pyinstaller -w test.py
here is the error i got
500 INFO: PyInstaller: 3.4
501 INFO: Python: 3.8.0
502 INFO: Platform: Windows-10-10.0.10240-SP0
512 INFO: wrote C:\Users\pheelz\Desktop\test.spec
538 INFO: UPX is not available.
568 INFO: Extending PYTHONPATH with paths
['C:\Users\pheelz\Desktop', 'C:\Users\pheelz\Desktop']
569 INFO: checking Analysis
1167 INFO: checking PYZ
1168 INFO: Building PYZ because PYZ-00.toc is non existent
1169 INFO: Building PYZ (ZlibArchive) C:\Users\pheelz\Desktop\build\test\PYZ-00.pyz
Traceback (most recent call last):
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\pheelz\AppData\Local\Programs\Python\Python38-32\Scripts\pyinstaller.exe__main__.py", line 7, in
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "c:\users\pheelz\appdata\local\programs\python\python38-32\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 "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py", line 784, in build
exec(text, spec_namespace)
File "", line 18, in
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 98, in init
self.postinit()
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in postinit
self.assemble()
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble
self.code_dict = {
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py", line 129, in
key: strip_paths_in_code(code)
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py", line 654, in strip_paths_in_code
consts = tuple(
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py", line 655, in
strip_paths_in_code(const_co, new_filename)
File "c:\users\pheelz\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py", line 662, in strip_paths_in_code
return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
As far as I can see, you are using PyInstaller 3.4 on Python 3.8.0.
PyInstaller works ONLY with Python 2.7 and 3.4—3.7 as stated here
Maybe you should downgrade your environment to Python 3.7.5
It seems that there are some issues for me to understand this error, I am trying to run setup.py and create a module or whatever it is called but even tho I installed markerlib it still throws an error.
any ideas?
PS D:\Python_Programming_Zed_Show\Python27_Projects\simple_solver> python setup.py sdist
running sdist
running egg_info
writing requirements to SIMPLE_SOLVER.egg-info\requires.txt
writing SIMPLE_SOLVER.egg-info\PKG-INFO
writing top-level names to SIMPLE_SOLVER.egg-info\top_level.txt
writing dependency_links to SIMPLE_SOLVER.egg-info\dependency_links.txt
Traceback (most recent call last):
File "setup.py", line 20, in <module>
setup(**config)
File "D:\Python27\lib\distutils\core.py", line 151, in setup
dist.run_commands()
File "D:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "D:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "d:\users\arhitect\downloads\distribute-0.7.3\distribute-0.7.3\setuptools\command\sdist.py", line 145, in run
self.run_command('egg_info')
File "D:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "D:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "d:\users\arhitect\downloads\distribute-0.7.3\distribute-0.7.3\setuptools\command\egg_info.py", line 177, in run
writer = ep.load(installer=installer)
File "d:\users\arhitect\downloads\distribute-0.7.3\distribute-0.7.3\pkg_resources.py", line 2241, in load
if require: self.require(env, installer)
File "d:\users\arhitect\downloads\distribute-0.7.3\distribute-0.7.3\pkg_resources.py", line 2254, in require
working_set.resolve(self.dist.requires(self.extras),env,installer)))
File "d:\users\arhitect\downloads\distribute-0.7.3\distribute-0.7.3\pkg_resources.py", line 2471, in requires
dm = self._dep_map
File "d:\users\arhitect\downloads\distribute-0.7.3\distribute-0.7.3\pkg_resources.py", line 2682, in _dep_map
self.__dep_map = self._compute_dependencies()
File "d:\users\arhitect\downloads\distribute-0.7.3\distribute-0.7.3\pkg_resources.py", line 2699, in _compute_dependencies
from _markerlib import compile as compile_marker
ImportError: No module named _markerlib
PS D:\Python_Programming_Zed_Show\Python27_Projects\simple_solver>
I am creating a bundled app with PyInstaller. The app includes numpy so the final size of the bundled app is > 600MB. I want of course to compress the size of the bundled app so I installed upx via brew install upx. However, PyInstaller crashes with the error below.
1- Is there any alternative to UPX or even PyIntaller for macOS?
2- Can I fix this error?
3- Can I run UPX manually after PyInstaller creates the bundled app on selected files? If yes, could you give an example of the command line for UPX?
Error:
Traceback (most recent call last):
File "/Users/Kenny/miniconda3/envs/umsap/bin/pyinstaller", line 11, in <module>
sys.exit(run())
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/__main__.py", line 111, in run
run_build(pyi_config, spec_file, **vars(args))
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/__main__.py", line 63, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 838, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 784, in build
exec(text, spec_namespace)
File "<string>", line 47, in <module>
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/osx.py", line 89, in __init__
self.__postinit__()
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
self.assemble()
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/osx.py", line 169, in assemble
fnm = checkCache(fnm, strip=self.strip, upx=self.upx, dist_nm=inm)
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/utils.py", line 228, in checkCache
dylib.mac_set_relative_dylib_deps(cachedfile, dist_nm)
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/depend/dylib.py", line 308, in mac_set_relative_dylib_deps
dll = MachO(libname)
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 95, in __init__
self.load(fp)
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 110, in load
self.load_header(fh, 0, size)
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 148, in load_header
hdr = MachOHeader(self, fh, offset, size, magic, hdr, endian)
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 188, in __init__
self.load(fh)
File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 293, in load
read_bytes, header.sizeofcmds))
ValueError: Read 1592 bytes, header reports 1992 bytes
Hi I have been trying to install Pandas for Python3.5 on AWS for the past couple of hours. I have googled and looked through a lot of posts related but still can't figure it out. Here's the error I get when I run sudo pip install pandas
You are using pip version 6.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pandas
Using cached pandas-0.20.3.tar.gz
Complete output from command python setup.py egg_info:
Running from numpy source directory.
/tmp/easy_install-t1qzuvjo/numpy-1.13.1/setup.py:367: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
run_build = parse_setuppy_commands()
/usr/lib64/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
warnings.warn(msg)
/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/system_info.py:572: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
self.calc_info()
/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/system_info.py:572: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
self.calc_info()
/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/system_info.py:572: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
self.calc_info()
/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/system_info.py:572: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
self.calc_info()
/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/system_info.py:572: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
self.calc_info()
/usr/lib64/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'define_macros'
warnings.warn(msg)
/usr/lib64/python3.5/distutils/dist.py:261: UserWarning: Unknown distribution option: 'python_requires'
warnings.warn(msg)
Traceback (most recent call last):
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 152, in save_modules
yield saved
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 193, in setup_context
yield
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 237, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 267, in run
return func()
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 236, in runner
_execfile(setup_script, ns)
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 46, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/setup.py", line 392, in <module>
"""Custom distutils command subclassed from Cython.Distutils.build_ext
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/setup.py", line 384, in setup_package
""" % src)
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/core.py", line 169, in setup
File "/usr/lib64/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/dist-packages/setuptools/command/bdist_egg.py", line 152, in run
self.run_command("egg_info")
File "/usr/lib64/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/egg_info.py", line 26, in run
File "/usr/lib64/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/build_src.py", line 148, in run
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/build_src.py", line 165, in build_sources
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/build_src.py", line 324, in build_extension_sources
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/build_src.py", line 377, in generate_sources
File "numpy/core/setup.py", line 421, in generate_config_h
tag = bdist_wheel.get_tag(self)
File "numpy/core/setup.py", line 47, in check_types
setuptools_kwargs = {}
File "numpy/core/setup.py", line 280, in check_types
pjoin(ujson_python,'JSONtoObj.c'),
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/tmp/pip-build-j9m4xuc4/pandas/setup.py", line 729, in <module>
**setuptools_kwargs)
File "/usr/lib64/python3.5/distutils/core.py", line 108, in setup
_setup_distribution = dist = klass(attrs)
File "/usr/lib/python3.5/dist-packages/setuptools/dist.py", line 265, in __init__
self.fetch_build_eggs(attrs['setup_requires'])
File "/usr/lib/python3.5/dist-packages/setuptools/dist.py", line 310, in fetch_build_eggs
replace_conflicting=True,
File "/usr/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 799, in resolve
dist = best[req.key] = env.best_match(req, ws, installer)
File "/usr/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 1049, in best_match
return self.obtain(req, installer)
File "/usr/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 1061, in obtain
return installer(requirement)
File "/usr/lib/python3.5/dist-packages/setuptools/dist.py", line 377, in fetch_build_egg
return cmd.easy_install(req)
File "/usr/lib/python3.5/dist-packages/setuptools/command/easy_install.py", line 642, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "/usr/lib/python3.5/dist-packages/setuptools/command/easy_install.py", line 672, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python3.5/dist-packages/setuptools/command/easy_install.py", line 857, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python3.5/dist-packages/setuptools/command/easy_install.py", line 1085, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python3.5/dist-packages/setuptools/command/easy_install.py", line 1071, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 240, in run_setup
raise
File "/usr/lib64/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 193, in setup_context
yield
File "/usr/lib64/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 164, in save_modules
saved_exc.resume()
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 139, in resume
compat.reraise(type, exc, self._tb)
File "/usr/lib/python3.5/dist-packages/setuptools/compat.py", line 65, in reraise
raise value.with_traceback(tb)
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 152, in save_modules
yield saved
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 193, in setup_context
yield
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 237, in run_setup
DirectorySandbox(setup_dir).run(runner)
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 267, in run
return func()
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 236, in runner
_execfile(setup_script, ns)
File "/usr/lib/python3.5/dist-packages/setuptools/sandbox.py", line 46, in _execfile
exec(code, globals, locals)
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/setup.py", line 392, in <module>
"""Custom distutils command subclassed from Cython.Distutils.build_ext
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/setup.py", line 384, in setup_package
""" % src)
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/core.py", line 169, in setup
File "/usr/lib64/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib64/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/dist-packages/setuptools/command/bdist_egg.py", line 152, in run
self.run_command("egg_info")
File "/usr/lib64/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/egg_info.py", line 26, in run
File "/usr/lib64/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib64/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/build_src.py", line 148, in run
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/build_src.py", line 165, in build_sources
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/build_src.py", line 324, in build_extension_sources
File "/tmp/easy_install-t1qzuvjo/numpy-1.13.1/numpy/distutils/command/build_src.py", line 377, in generate_sources
File "numpy/core/setup.py", line 421, in generate_config_h
tag = bdist_wheel.get_tag(self)
File "numpy/core/setup.py", line 47, in check_types
setuptools_kwargs = {}
File "numpy/core/setup.py", line 280, in check_types
pjoin(ujson_python,'JSONtoObj.c'),
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
non-existing path in 'numpy/distutils': 'site.cfg'
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’ [enabled by default]
int exp (void);
^
_configtest.o: In function `main':
/tmp/easy_install-t1qzuvjo/numpy-1.13.1/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status
_configtest.o: In function `main':
/tmp/easy_install-t1qzuvjo/numpy-1.13.1/_configtest.c:6: undefined reference to `exp'
collect2: error: ld returned 1 exit status
_configtest.c:1:5: warning: conflicting types for built-in function ‘exp’ [enabled by default]
int exp (void);
^
_configtest.c:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
_configtest.c:1:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-j9m4xuc4/pandas
I have tried uninstalling/installing pandas, numpy.
My pip version seems to be a bit weird:
$ pip --version
pip 9.0.1 from /home/ec2-user/.local/lib/python2.7/site-packages (python 2.7)
$ pip3 --version
pip 6.1.1 from /usr/lib/python3.5/dist-packages (python 3.5)