python and py2app mac osx 10.7 - python

i want to create .app application by Py2app, i was installed Py2app on my mac os x lion by terminal and copy "gtkapp.py" (the name of my app that used PyGTK) and "setup.py" but when i run the setup.py get this error:
from setuptools import setup
and
ImportError: cannot import name setup
what problem?

Be sure the py2app binary is in your path. A simple way around this is to use MacPorts for your py2app isntallation.

Related

Kivy for Python 3 on a Mac OS X

I was wondering if kivy supports Python 3 on Mac OS X systems. From the download page from the kivy official website, it seems that kivy-1.9.0 is available for Python 3.4 for Windows systems, but it does not seem to support Python 3 on Mac OS X:
Mac OS X Mac OS X 10.9, 10.10 (requires Python 2.7)
Kivy-1.9.0-rev3-osx.dmg (Mirror)
This seems a little but nonsensical, why kivy should support Python 3 on Windows but not on a Mac OS X? It could be because of the missing support of PyGame for Python 3 for OS X systems? Actually, there's a way to install PyGame for OS X systems for Python 3, so I do not understand why they do not fix this problem, if this is really a problem.
I have also tried to install it globally via pip3 using:
sudo pip3 install kivy
But I am getting the following error:
Collecting kivy Downloading Kivy-1.9.0.tar.gz (16.2MB)
100% |████████████████████████████████| 16.2MB 34kB/s
Complete output from command python setup.py egg_info:
Cython is missing, its required for compiling kivy !
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "/private/tmp/pip-build-qt70t_44/kivy/setup.py", line 173, in <module>
from Cython.Distutils import build_ext
ImportError: No module named 'Cython'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-qt70t_44/kivy
You will need to build from source.
As a previous poster mentioned, you will need to get Cython installed.
To get the latest version, use
$ pip3 install cython
From there, you need to modify setup.py. Here's an example of how I did it.
According to the error message, you are missing the package cython:
Cython is missing, its required for compiling kivy !
...
ImportError: No module named 'Cython'
You should run pip install cython.
Then installing from source worked for me, by opposition to using pip.

py2exe cannot import from six.py

I'm trying use py2exe on a program that imports urlparse from six.moves.urllib_parse. Here is the program:
# hello.py
from six.moves.urllib_parse import urlparse
print('hello world')
And here is my setup.py:
from distutils.core import setup
import py2exe
setup(console=['hello.py'])
Running hello.py works fine. When I compile hello.py into an exe using python setup.py py2exe, a hello.exe file is produced. However, when I run hello.exe I get an error saying:
ImportError: No module named urlparse
I'm using Python 2.7.
With Python 3.4, I get an error saying KeyError: 'six.moves' when running python setup.py py2exe.
How can I stop these errors from occurring?
The problem is just that py2exe doesn't detect the modules that are proxied through six, so they're not bundled.
All you have to do is add the module in question (urlparse) to your includes in your setup.py:
options={
"py2exe": {
...
"includes": ["urlparse"],
...
That way the module will be packaged, and when six tries to import it, it will work.
py2exe released a new version recently that fixes this problem:
Changes in version 0.9.2.2:
- Added support for six, cffi, pycparser, openssl.
Using this version I was able to create an .exe and run it successfully.

Py2app Problems : Setup Tools

I've recently installed the latest version of Py2app on my Mac Os X (10.5.8), and I've watched some tutorials on YouTube such as: http://www.youtube.com/watch?v=Zip9H_dLdhI, and http://www.youtube.com/watch?v=5Ehhts9HhE8, but when I copy their main setup code, it gives me an ImportError:
Traceback (most recent call last):
File "/Users/CarlProject/Rectangles Backup.py", line 7, in <module>
from setuptools import setup
ImportError: No module named setuptools
This is my setup code, copied and edited from the first YouTube video:
"""
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['Rectangles.py']
DATA_FILES = [('', ['fonts'])]
setup(
app = APP,
data_files = DATA_FILES,
setup_requires = ['py2app'],
)
My Python version is 2.7.5, and I'm using Pygame. The Py2app is the latest: 0.7.3. Yes, everything is on my desktop, and I've installed setuptools 0.9.8 Help!
Just incurred in the same problem but found the solution.
"For ease of distribution, you may wish to have your setup.py script automatically ensure that setuptools is installed. This requires having a copy of ez_setup in your project, which can be obtained from here:"
http://peak.telecommunity.com/dist/ez_setup.py
(Save it in your project directory with .py extension)
"Once this is done, you simply add the two line ez_setup preamble to the very beginning of your setup.py:"
import ez_setup
ez_setup.use_setuptools()
Source: https://pythonhosted.org/py2app/examples.html
You need to install setuptools.
Download it from here and then check this out to learn how to install it:
Python Setuptools, easy_install setup mac

How Can I Make A Windows Executable With Pyserial?

I am trying to make an executable of a Stackless Python 2.6 program. The setup file is
from distutils.core import setup
import py2exe
setup(console=['controller.py'])
and I run it with
python setup.py py2exe
However, when I try to run it, it raises an ImportError and says that there is no module named serial. When I try:
python setup.py py2exe --includes serial
or
python setup.py py2exe --includes pyserial
the build fails with an ImportError. Do you have any ideas?
Had same issue. Upgrading pyserial to 2.5 solved the problem: exec built without additional "includes" contains pyserial.

pyqt installation problem in mac osx snow leopard

I'm following a tutorial of making desktop apps. with python and qt4, I downloaded and installed qt creator ide, created the .ui file and then I had to convert it using pyuic4, I've been trying a lot of things and still can't do it.
I thought that pyuic4 would be installed with Qt creator IDE, but it seems that's not the case, so I installed pyqt through macports:
sudo port install py26-pyqt4
I didn't know but that came with qt, so it was about 3 hours building it.
after installing it I tried to convert the .ui again:
$ pyuic4-2.6 principal.ui -o prin.py
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PyQt4/uic/pyuic.py", line 4, in <module>
from PyQt4 import QtCore
ImportError: No module named PyQt4
No module named PyQt4? wasn't that what I just installed?
Thanks, and excuse me if my english isn't 100% good.
I've solved it, you have to use the python of macports instead of the default that comes with OS X, to do that install python_select through macports:
sudo port install python_select
sudo python_select python26
I made some notes on building and install PyQt4 on Mac Snow Leopard.
The order is important, and there are some quirks with 64-bit libraries. The default Mac Qt libs are Carbon (32 bit), whereas Mac system Python is 64 bit and needs the Cocoa libs.
I spent a while finding the package name in Homebrew. It seems to be:
brew install pyqt

Categories