I want to build_ext a ".pyd" file but it didn't work.
I tried to update visual, update compilers etc .. nothing worked ...
I want to use this command:
python setup.py build_ext --inplace --compiler=cygwin
with setup.py:
from distutils.core import setup
from Cython.Build import cythonize
import os
os.environ["CC"] = "gcc-5.3.0"
os.environ["CXX"] = "gcc-5.3.0"
directives = {'linetrace': False, 'language_level': 3}
setup(ext_modules = cythonize('local_correlation.cp37-win_amd64.pyd'))
and i have it :
running build_ext
Traceback (most recent call last):
File "setup.py", line 15, in <module>
setup(ext_modules = cythonize('local_correlation.cp37-win_amd64.pyd'))
File "C:\Users\benfr\Anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\benfr\Anaconda3\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\benfr\Anaconda3\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\benfr\Anaconda3\lib\distutils\command\build_ext.py", line 308, in run
force=self.force)
File "C:\Users\benfr\Anaconda3\lib\distutils\ccompiler.py", line 1031, in new_compiler
return klass(None, dry_run, force)
File "C:\Users\benfr\Anaconda3\lib\distutils\cygwinccompiler.py", line 137, in __init__
if self.ld_version >= "2.10.90":
TypeError: '>=' not supported between instances of 'NoneType' and 'str'
Related
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 have already create an issue in github. But no one reply.
The question is:
I runpython3 setup.py py2app and the error:
Traceback (most recent call last):
File "/Users/th/source/duomai/send_email.py/setup.py", line 14, in <module>
setup(
File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/usr/local/Cellar/python#3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/Cellar/python#3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 966, in run_commands
self.run_command(cmd)
File "/usr/local/Cellar/python#3.9/3.9.0_5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/distutils/dist.py", line 985, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 925, in run
self._run()
File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1147, in _run
self.run_normal()
File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1244, in run_normal
self.process_recipes(mf, filters, flatpackages, loader_files)
File "/usr/local/lib/python3.9/site-packages/py2app/build_app.py", line 1099, in process_recipes
rval = check(self, mf)
File "/usr/local/lib/python3.9/site-packages/py2app/recipes/sip.py", line 111, in check
mf.import_hook("sip", m)
File "/usr/local/lib/python3.9/site-packages/modulegraph/modulegraph.py", line 1114, in import_hook
q, tail = self._find_head_package(parent, name, level)
File "/usr/local/lib/python3.9/site-packages/modulegraph/modulegraph.py", line 1215, in _find_head_package
raise ImportError("No module named " + qname)
ImportError: No module named sip
And my setup.py
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['cli.py']
DATA_FILES = []
OPTIONS = {}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
It's seems like qt relative. But I didn't used qt, I just use the tkinter...
The detail log is long, I create an attach. https://www.dropbox.com/s/4pcc9zv7dgoq37j/log.txt?dl=0
How to fix this?
Try adding the packages to your options in the setup file, like this:
OPTIONS = {
'argv_emulation': True,
'packages':['tkinter']}
I'm trying to compile python script to exe.
My script - hello.py:
print("hello")
My setup.py:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
name = 'hello',
description = 'hello script',
version = '1.0',
options = {'py2exe': {'bundle_files': 1, 'compressed': True,'dist_dir': ".",'dll_excludes':['w9xpopen.exe']}},
console = [{'script': r"hello.py"}],
zipfile = None,
)
I run:
py -3 setup.py install
The error:
py -3 setup.py install
running install
running build
running install_egg_info
Removing C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\hello-1.0-py3.7.egg-info
Writing C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\hello-1.0-py3.7.egg-info
running py2exe
Traceback (most recent call last):
File "setup.py", line 19, in <module>
zipfile = None,
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 966, in run_commands
self.run_command(cmd)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\distutils\dist.py", line 985, in run_command
cmd_obj.run()
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\distutils_buildexe.py", line 188, in run
self._run()
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\distutils_buildexe.py", line 267, in _run
builder.analyze()
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\runtime.py", line 160, in analyze
self.mf.import_hook(modname)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
module = self._gcd_import(name)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
return self._find_and_load(name)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 357, in _find_and_load
self._scan_code(module.__code__, module)
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 388, in _scan_code
for what, args in self._scan_opcodes(code):
File "C:\Users\alonat\AppData\Local\Programs\Python\Python37-32\lib\site-packages\py2exe\mf3.py", line 417, in _scan_opcodes
yield "store", (names[oparg],)
IndexError: tuple index out of range
Do you know how to resolve this error?
py2exe seems to support up to Python 3.4 (thanks Michael Butscher)
However, there are other libraries such as Pyinstaller which work just fine, and are compatible with a variety of Python versions (from Python 2.7 to 3.5+)
Check it out, it's actually really easy :)
https://pyinstaller.readthedocs.io/en/stable/
I am using cx_Freeze with Python 3.4.1 and I am trying to create an application from one of my Python programs. Unfortunately, I get this error after running the setup.py build:
cx_Freeze.freezer.ConfigError: cannot find file/directory named icon.gif
Here is my setup file:
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32" : base = "Win32GUI"
opts = {"include_files": ['icon.gif', "EndingsPerfect.txt", "EndingsPPP.txt", "LatinEnglishPronouns.txt", "1stConj/", "2ndConj/", "3rdConj/", "4thConj/"], "includes": ["re"]}
setup(name = "LT",
version = "1.0",
description = "Latin verbs",
author = "Laurence vS",
options = {"build_exe": opts},
executables = [Executable("latintranslatewithguipyw.pyw", base = base)])
This error confuses me since the icon.gif file is in the same folder as the setup file.
Here is the full traceback:
C:\Users\Laurence> python "C:\Users\Laurence\Dropbox\Python programs\GUIs\latintr
anslatewithgui\setup.py" build
running build
running build_exe
Traceback (most recent call last):
File "C:\Users\Laurence\Dropbox\Python programs\GUIs\latintranslatewithgui\set
up.py", line 14, in <module>
executables = [Executable("latintranslatewithguipyw.pyw", base = base)])
File "C:\Python34\lib\site-packages\cx_Freeze\dist.py", line 362, in setup
distutils.core.setup(**attrs)
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\distutils\command\build.py", line 126, in run
self.run_command(cmd_name)
File "C:\Python34\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\site-packages\cx_Freeze\dist.py", line 231, in run
metadata = metadata)
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 108, in __init
__
self._VerifyConfiguration()
File "C:\Python34\lib\site-packages\cx_Freeze\freezer.py", line 498, in _Verif
yConfiguration
sourceFileName)
cx_Freeze.freezer.ConfigError: cannot find file/directory named icon.gif
Any help would be appreciated.
Reposting as an answer:
Relative path names are found relative to where you run from, not where the the setup.py script is. Use cd in the terminal to change to the directory where setup.py is, and then run python setup.py build.
If that's not practical for some reason, you could use os.chdir() inside the setup.py script.
Compiling .pyx files was working fine but suddenly it started raising error when I type:
python setup.py build_ext --inplace
I get the error:
c:\Python27\cython\helloworld>python setup.py build_ext --inplace
running build_ext
cythoning hello.pyx to hello.c
Traceback (most recent call last):
File "setup.py", line 8, in <module>
ext_modules = [Extension("hello", ["hello.pyx"])]
File "C:\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\Cython\Distutils\build_ext.py", line 163,
in run
_build_ext.build_ext.run(self)
File "C:\Python27\lib\distutils\command\build_ext.py", line 340, in run
self.build_extensions()
File "C:\Python27\lib\site-packages\Cython\Distutils\build_ext.py", line 170,
in build_extensions
ext.sources = self.cython_sources(ext.sources, ext)
File "C:\Python27\lib\site-packages\Cython\Distutils\build_ext.py", line 317,
in cython_sources
full_module_name=module_name)
File "C:\Python27\lib\site-packages\Cython\Compiler\Main.py", line 605, in com
pile
return compile_single(source, options, full_module_name)
File "C:\Python27\lib\site-packages\Cython\Compiler\Main.py", line 546, in com
pile_single
return run_pipeline(source, options, full_module_name)
File "C:\Python27\lib\site-packages\Cython\Compiler\Main.py", line 386, in run
_pipeline
import Pipeline
File "C:\Python27\lib\site-packages\Cython\Compiler\Pipeline.py", line 7, in <
module>
from Visitor import CythonTransform
File "Visitor.py", line 9, in init Cython.Compiler.Visitor (Cython\Compiler\Vi
sitor.c:12838)
File "C:\Python27\lib\site-packages\Cython\Compiler\Nodes.py", line 6, in <mod
ule>
cython.declare(sys=object, os=object, copy=object,
AttributeError: 'module' object has no attribute 'declare'
I tried running it on a simple .pyx file helloworld:
def say_hello_to(name):
print "Hello %s!" %name
with the setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("hello", ["hello.pyx"])]
)
It already worked several times, something has changed but as I Googled and searched the issue I couldn't find any information. I'm using Python 2.7 64 bits, latest version of Cython and to compile the file I use Windows SDK C/C++ compiler and prepare the environment by running:
C:\Program Files\Microsoft SDKs\Windows\v7.0>set DISTUTILS_USE_SDK=1
C:\Program Files\Microsoft SDKs\Windows\v7.0>setenv /x64 /release
Any ideas of what might have happened? Tnx in advance!
I got the same error when running from a python script:
os.system("python setup.py build_ext --inplace")
while
python setup.py build_ext --inplace
worked from command promt.
The reason was that the name of my test package was "cython"... stupid me
I have had the same error.
Worked on it for one whole day until I have realized that I have followed some blog entry to create a cython.py file in my directory holding some information how to compile.
I do not recall where I found this but by removing this file everything works fine
I'm not sure this helps, but when I got this error I deleted all .pyc files and ran the script again via IDLE (opened in IDLE and clicked F5) and then it worked just fine.