cx_Freeze successfully converts a .py file to an .exe if no other packages are involved.
But when pandas is included, the setup fails with this message:
File "C:\Anaconda\lib\site-packages\cx_Freeze\hooks.py", line 1324, in load_zmq
libzmq = __import__("zmq", fromlist=["libzmq"]).libzmq
AttributeError: module 'zmq' has no attribute 'libzmq'
This is the contents of the setup.py:
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["pandas"]}
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup( name = "test",
version = "0.1",
options = {"build_exe": build_exe_options},
executables = [Executable("test.py", base=base)])
So far I've tried creating a different environment in anaconda to run cx_freeze to see if the problem resolves itself that way.
Appreciate any help.
I've spent a long time trying to find an answer to this question, but luckily it can be found here. It seems it was a bug inherent to cx_freeze.
Although the link provided to download the wheels no longer works, the patch has been added to the latest development version (6.6.0 if I recall correctly). You can install it directly from github, as such:
python -m pip install git+https://github.com/marcelotduarte/cx_Freeze.git
Doing this fixed the error for me (and enabled me to discover other errors that I had to deal with!).
Related
I am making a project with Django and pytube in python 3.6, but when I run the code below in my python anywhere project, I get this error:
AttributeError : module 'pytube' has no attribute 'YouTube'.
import pytube
url = input()
yt = pytube.YouTube(url)
This probably is because there are multiple packages named pytube, and I think that I installed the wrong one. Which one do I have to install? And should I than use pip or pip3?
I already tried uninstalling pytube and reinstalling (also via the GitHub link which you can find from other people who are having issues with this: git+https://github.com/nficano/pytube.git)
I just read the Cython Pure Python Mode documentation and I'm not sure if I understand it right. It sounds as if I could keep all my Python files as they are, add *.pxd files where I declare Cython types. In the setup.py, I still add
from setuptools import setup
from Cython.Build import cythonize
setup(
ext_modules = cythonize(
"A.py",
compiler_directives={'language_level' : "3"}
)
)
When I run python setup.py build_ext --inplace it actually builds the .so file.
What happens when I create the sdist / bdist, upload them to PyPI and a user does not have a matching platform? They will download the sdist, sure. I guess pip / setuptools will automatically try to compile the extension modules (A.py) and I guess if that works, it is fine. But what if cythonize fails? Will it still install the package and use the pure Python code?
I don't think so. I believe a failure in setup.py aborts installation completely.
You can try to declare an extension optional but there're reports that doesn't really work. Could be an issue with older setuptools.
I need to install a specific public package for one of my projects. I tried to do:
from setuptools import setup, find_packages
setup(
name = 'aaa',
install_requires = ['hyperas==0.3']
dependency_links = ['git+https://github.com/maxpumperla/hyperas.git#egg=hyperas-0.3']
)
But gave up because I couldn't get it to work and it was being deprecated. What is the correct way to tell pip to download a package from a particular url rather than from PyPi?
The url I need is https://github.com/maxpumperla/hyperas, rather than https://pypi.python.org/pypi/hyperas. Is this possible?
I am using Python 2.7 through Anaconda 2.7.8 and need Kapteyn 2.2 to perform Non-linear Least Squares fitting easily (it is probably an alternative to Scipy.optimize.leastsq() for dummies like me!).
After copy-pasting this from a previous post here on Stack Overflow:
conda install -c https://conda.binstar.org/dhirschfeld pyodbc
and then running on my cmd (as I did not have pyodbc installed I think, because of which maybe the command prompt on my Windows 7 64-bit system was not responding well to python setup.py install inside the Anaconda directory where I unzipped the Kapteyn .zip file downloaded from University of Groningen website.
But, after the installing pyodbc properly and running python setup.py install, the cmd gave me an error saying error: command 'C:\Users\windows 7\Anaconda\Scripts\gcc.bat' failed with exit status 1. Later, when I tried to import kmpfit module (needed for Non-linear least square fitting with Kapteyn), here is the problem:
import kapteyn
help(kapteyn)
Help on package kapteyn:
NAME
kapteyn - Kapteyn package.
FILE
c:\users\windows 7\anaconda\kapteyn\__init__.py
PACKAGE CONTENTS
_ni_support
celestial
doccer
filters
interpolation
maputils
mplutil
positions
rulers
shapes
tabarray
wcsgrat
DATA
__all__ = ['celestial', 'wcs', 'wcsgrat', 'tabarray', 'maputils', 'mpl...
__version__ = '2.2'
VERSION
2.2
As you can see, there is no module named kmpfit (or even wcs) here. But according to http://www.astro.rug.nl/software/kapteyn/intro.html, these two should be there.
Kindly help. I have never imported any module before.
Thanks in advance...:-)
I just managed to get this working (on Mac OSX, so you may have to adjust this). My steps were:
$ conda install pyodbc (didn't need to go through binstar)
Download & unarchive the kapteyn package, then navigate to its directory
$ python setup.py install, which used my OS's C compiler and Anaconda's python, and installed kapteyn to my anaconda distro's site-packages, as it should.
Check that kmpfit.so is in the kapteyn folder in site-packages, showing that kmpfit installed correctly.
>> from kapteyn import kmpfit failed, ImportError: cannot import name kmpfit. I did some digging and discovered that it was still importing kapteyn from the folder that I downloaded, not from site-packages.
Delete the downloaded kapteyn folder, then try again. It worked!
I have this problem when I try to generate an app executable. I follow this example so the code for the setup would be
application_title = "app_name" #what you want to application to be called
main_python_file = "main.py" #the name of the python file you use to run the program
import sys
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
includes = ["atexit","re"]
setup(
name = application_title,
version = "0.1",
description = "Sample cx_Freeze PyQt4 script",
options = {"build_exe" : {"includes" : includes }},
executables = [Executable(main_python_file, base = base)])
then I go to my terminal and press
python setup.py bdist_mac
for some reason that I do not know how to solve I get this output, and the file it is not generated
running bdist_mac
running build
running build_exe
copying /Applications/anaconda/lib/python3.4/site-packages/cx_Freeze/bases/Console -> build/exe.macosx-10.5-x86_64-3.4/main
copying /opt/local/Library/Frameworks/Python.framework/Versions/3.4/Python -> build/exe.macosx-10.5-x86_64-3.4/Python
error: [Errno 2] No such file or directory: '/opt/local/Library/Frameworks/Python.framework/Versions/3.4/Python'
I have installed anaconda with Python 3.4 and cx_freeze. Any suggestions?
I met the same problem and it is fixed by installing a separated python besides anaconda. It seems to be similar with the problem here
py2app is not copying the Python.framework to the new app while using virutalenv