Upgrading py2app with pip breakes it - python

I upgraded py2app (using pip) and then ran
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/bin/py2applet --make-setup --arch=i386 test.py
However I get the following
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/bin/py2applet", line 5, in <module>
from pkg_resources import load_entry_point
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2797, in <module>
parse_requirements(__requires__), Environment()
File "/Library/Python/2.7/site-packages/pkg_resources.py", line 576, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: py2app==0.6.3
I don't want to use 0.6.3 why is it forcing me to?

It looks like the py2applet shell script has an explicit exit call that checks the py2app version. Updating it to the latest seemed to do the trick. I have two parallel installs of python, the native OS X one and one from MacPorts. Somehow the py2applet script wasn't taken into account after updating the port. I wouldn't recommend this method for other distributions but on a Mac this seems to me a viable solution.
#!/usr/bin/python
__requires__ = 'py2app==0.8'
import sys
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('py2app==0.8', 'console_scripts', 'py2applet')()
)
By the way you can find the version number by importing py2app in the python shell:
python
import py2app
py2app.__version__
Gives me:
'0.8'

Related

Enthought Canopy not working on Fedora. Giving error related to Zlib not found

I installed canopy from the .sh file provided from the link of the Enthought canopy site and then ran the following command after cd into the Canopy directory.
Ashish#LoneWarrior Canopy]$ ./canopy
Subprocess output:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64 /lib/python2.7/site-packages/pyface/gui.py", line 20, in <module>
from .toolkit import toolkit_object
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 99, in <module>
_init_toolkit()
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 65, in _init_toolkit
be = import_toolkit(ETSConfig.toolkit)
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/toolkit.py", line 58, in import_toolkit
__import__(be + 'init')
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/ui/qt4/init.py", line 18, in <module>
from pyface.qt import QtCore, QtGui, qt_api
File "/home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/lib/python2.7/site-packages/pyface/qt/QtGui.py", line 8, in <module>
from PySide.QtGui import *
This is the main error : ZLIB_1.2.9 not found.
ImportError: /home/Ashish/Canopy/appdata/canopy-2.1.3.3542.rh6-x86_64/bin/../lib/libz.so.1: version `ZLIB_1.2.9' not found (required by /lib64/libpng16.so.16)
I have tried changing the python default to 3 but still it is not working.
I presume the problem is on an Arch-based distribution. The temporary solution in this case is to downgrade libpng to 1.6.28 (this worked in my case). If you don't have it in your cache (`/var/cache/pacman/pkg'), you can download it from https://archive.archlinux.org/packages/l/libpng/
Then, following https://wiki.archlinux.org/index.php/downgrading_packages run in the directory with the downloaded file
# pacman -U libpng-1.6.28-1-x86_64.pkg.tar.xz
(with the correct architecture, of course)
Don't forget to list libpng in /etc/pacman.conf among ignored packages to prevent upgrading. Look for the [options] section and add IgnorePkg = libpng.
Improtant. Keep in mind that downgrading packages is not harmless, therefore, this is only a temporary solution.
The problem is that the libz file in the canopy environment is not compatible with the ZLIB installed in your system.
For a quick fix: just copy the libz.so.1 file from lib directory to your canopy environment.
In my case it was
$ cp /usr/lib/libz.so.1 path-to-Canopy-install-directory/appdata/canopy-2.1.6.3665.rh6-x86_64/lib/libz.so.1

If I have Pandas installed correctly, why won't my import statement recognize it?

I'm working on a project to play around with a csv file, however, I can't get pandas to work. Everything I have researched so far has just told me to make sure that pandas is installed. Using pip I have managed to install pandas just fine. When I try to run my python program and import pandas I get:
Traceback (most recent call last):
File "analysis.py", line 1, in <module>
import pandas as pd
ImportError: No module named pandas
I don't know if this is related, but I was trying to see see if this would work with conda install pandas however, I get this import error:
(Again, Anaconda is correctly installed on my system)
Traceback (most recent call last):
File "/usr/local/bin/conda", line 9, in <module>
load_entry_point('conda==4.2.7', 'console_scripts', 'conda')()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2627, in load_entry_point
return ep.load()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2287, in load
return self.resolve()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2293, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Python/2.7/site-packages/conda/cli/__init__.py", line 8, in <module>
from .main import main # NOQA
File "/Library/Python/2.7/site-packages/conda/cli/main.py", line 46, in <module>
from ..base.context import context
File "/Library/Python/2.7/site-packages/conda/base/context.py", line 18, in <module>
from ..common.configuration import (Configuration, MapParameter, PrimitiveParameter,
File "/Library/Python/2.7/site-packages/conda/common/configuration.py", line 40, in <module>
from ruamel.yaml.comments import CommentedSeq, CommentedMap # pragma: no cover
ImportError: No module named ruamel.yaml.comments
Anyone have a similar experience importing libraries? I have tried to make sure that I have the correct versions for Python3 but that doesn't seem to be the issue. Any help would be greatly appreciated! Thank you.
The problem is that the 'lib' folder that pip installs things into has a separate subdirectory for each python environment that you're working with (by default this is python2.7). A simple workaround is to build a virtual environment of python3 and then installing pandas or whatever package you want into it. To achieve this, try the following:
virtualenv -p /usr/bin/python3 python3
Now, each time you want to pip install a python3 package, run
source python3/bin/activate
pip install pandas --user
Hope this helps
Go to powershell on your system and pip install pandas. you will see a successfully installed command. you can install other modules too like matplotlib et al.

Install sage script using setuptools

I am trying to build an installer for a sage script using setuptools. Here is what I have.
My setup.py file:
#!/usr/bin/env python2
from setuptools import setup
__name__ = 'sage-test'
__version__ = '0.0'
setup(name=__name__,
scripts=['sage-test'],
)
The sage-test file:
#!/usr/bin/env sage
from sage.all import GF
print(GF(5))
I now do ./setup.py build and ./setup.py install. When I try to run sage-test, I get the following error:
Traceback (most recent call last):
File "/usr/bin/sage-test", line 4, in <module>
__import__('pkg_resources').run_script('sage-test==0.0.0', 'sage-test')
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 517, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1443, in run_script
exec(script_code, namespace, namespace)
File "/usr/lib/python2.7/site-packages/sage_test-0.0.0-py2.7.egg/EGG-INFO/scripts/sage-test", line 3, in <module>
__requires__ = 'sage-test==0.0.0'
ImportError: No module named sage.all
Any ideas how to get this to work? (Note that I can run ./sage-test within the current directory and everything works.)
This may not help, but this looks suspicious.
/usr/lib/python2.7/
Maybe you need to do everything within sage -sh - I wouldn't be surprised if there was some env var that was not set up properly. I don't know exactly why but maybe it's picking up your system Python somehow.

easy_install conflict for python2.4 and python2.7

I have installed python under /opt/python2.7.1/ on CentOS machine which has already python2.4 and configure it to run python2.7 default.
However, when I write 'easy_install' it raises error like
Traceback (most recent call last):
File "/opt/python2.7.1/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2482, in ?
for dist in working_set.resolve(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==0.6c11
I think easy_install under /usr/bin/ links to python2.4. How can I run /opt/python2.7.1/bin/easy_install default?
For $PATH:
/opt/python2.7.1/bin:/usr/devs/bin:/usr/local/bin:/bin:/usr/bin:/home/ops/bin
For $LD_LIBRARY_PATH:
/opt/python2.7.1/lib:
For easy_install:
Traceback (most recent call last):
File "/opt/python2.7.1/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 2482, in ?
for dist in working_set.resolve(
File "/usr/lib/python2.4/site-packages/pkg_resources.py", line 483, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==0.6c11
You have to make use of virtualenv to get things working properly, and without worries in systems with more than one Python version.
Actually, it is quite a help even in system qwith a single Python version, if you have muliple Python apps running.
Visrtualenv will not only take care of setting up all the appropriate environment variables for you to use one Python or another, as it will allow you to use use a separate environment where you can safely "easy_install" Python 2.4 modules without conflicting with CentOS .rpm packages of those same modules.

Django throws an ImportError on Mac OS X

I'm trying to get a work project that I git-cloned from work (used in numerous other places, I know the project works fine) to run on my MacBook. I installed Django (via sudo python setup.py install), as well as MySQL, the Python MySQL wrapper, and also virtualenv with virtualenvwrapper.
After creating a virtualenv for my project (virtualenv is created fine), and doing a pip install for the project requirements (all of which install into the proper virtualenv directory), an attempt to do a runserver command spits out the following:
Traceback (most recent call last):
File "manage.py", line 12, in <module>
execute_manager(settings)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 436, in execute_manager
setup_environ(settings_mod)
File "/Library/Python/2.6/site-packages/django/core/management/__init__.py", line 419, in setup_environ
project_module = import_module(project_name)
File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
ImportError: No module named website-backend
First try to import this library from python or ./manage.py shell.
If that fails import sys and check if your lib is in sys path print sys.path

Categories