Discussion:
[PEAK] peak/utils/addons import problem
nicky van foreest
2011-10-23 22:34:50 UTC
Permalink
Hi,

I updated my ubuntu version just now, and it broke my working trellis
installation. Yesterday everything worked just fine. Does anybody have
an idea what might be wrong? I did not change my pythonpath, or
anything else. I also tried reinstalling trellis, but to no avail.

Thanks in advance

Nicky

PS. Some things I checked:

in ipython the auto-completion on from peak.events works. Apparently,
python can find peak.events. However, from peak.utils fails.



***@chuck:~/lib/python$ cat easy-install.pth
import sys; sys.__plen = len(sys.path)
./Trellis-0.7a2
./Contextual-0.7a1.dev_r2695-py2.7.egg
./DecoratorTools-1.8-py2.7.egg
./AddOns-0.7-py2.7.egg
./SymbolType-1.0-py2.7.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:];
p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert =
p+len(new)


***@chuck:~/lib/python$ env |grep PY
PYTHONPATH=/home/nicky/myprogs/python/:/home/nicky/lib/python/:.


***@chuck:~/lib/python$ python
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
nicky van foreest
2011-10-23 22:38:24 UTC
Permalink
I did some tinkering with easy-install.pth. The output in my previous
mail is not correct. This is correct:

***@chuck:~/lib/python$ cat easy-install.pth
import sys; sys.__plen = len(sys.path)
./Trellis-0.7a2
./Extremes-1.1.1-py2.7.egg
./Contextual-0.7a1.dev_r2695-py2.7.egg
./DecoratorTools-1.8-py2.7.egg
./AddOns-0.7-py2.7.egg
./SymbolType-1.0-py2.7.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:];
p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert =
p+len(new)

To check whether there was a problem with Extremes I just deleted the
associated line, but this did not change anything, at least not
noticeable.
PJ Eby
2011-10-23 23:55:07 UTC
Permalink
Post by nicky van foreest
Hi,
I updated my ubuntu version just now, and it broke my working trellis
installation.
You'll need to be more specific about "broke". Do you have a traceback?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20111023/b20f2715/attachment.html
nicky van foreest
2011-10-24 08:02:41 UTC
Permalink
HI,

This is what I get

***@chuck:~/myprogs/python/an$ python view.py
Traceback (most recent call last):
File "view.py", line 11, in <module>
from peak.events import trellis
File "/home/nicky/lib/python/Trellis-0.7a2-py2.7.egg/peak/events/trellis.py",
line 3, in <module>
from peak.util import addons, decorators
ImportError: cannot import name addons

So why can peak.events.trellis be found, but peak.util.addons not?

Nicky
Post by nicky van foreest
Hi,
I updated my ubuntu version just now, and it broke my working trellis
installation.
You'll need to be more specific about "broke". ?Do you have a traceback?
PJ Eby
2011-10-24 15:37:49 UTC
Permalink
Perhaps Ubuntu dropped the addons package, or split it into a separate
package? Install AddOns from PyPI, and see what happens.
Post by nicky van foreest
HI,
This is what I get
File "view.py", line 11, in <module>
from peak.events import trellis
File
"/home/nicky/lib/python/Trellis-0.7a2-py2.7.egg/peak/events/trellis.py",
line 3, in <module>
from peak.util import addons, decorators
ImportError: cannot import name addons
So why can peak.events.trellis be found, but peak.util.addons not?
Nicky
Post by PJ Eby
Post by nicky van foreest
Hi,
I updated my ubuntu version just now, and it broke my working trellis
installation.
You'll need to be more specific about "broke". Do you have a traceback?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20111024/a800b4cf/attachment.html
nicky van foreest
2011-10-24 15:51:14 UTC
Permalink
Hi,

Thanks. I did not install trellis as an ubuntu package as it is not
available as a package. I used easy_install trellis. After the
problems occurred I reinstalled trellis with easy_install but the
problem of not being able to find Addons remains. Any idea? Perhaps
the simplest solution would be to just copy peak/util and peak/events
to my python library and adjust the pythonpath accordingly. Or is this
too simplistic?

NIcky
Post by PJ Eby
Perhaps Ubuntu dropped the addons package, or split it into a separate
package? ?Install AddOns from PyPI, and see what happens.
Post by nicky van foreest
HI,
This is what I get
?File "view.py", line 11, in <module>
? ?from peak.events import trellis
?File
"/home/nicky/lib/python/Trellis-0.7a2-py2.7.egg/peak/events/trellis.py",
line 3, in <module>
? ?from peak.util import addons, decorators
ImportError: cannot import name addons
So why can peak.events.trellis be found, but peak.util.addons not?
Nicky
On Sun, Oct 23, 2011 at 5:34 PM, nicky van foreest
Post by nicky van foreest
Hi,
I updated my ubuntu version just now, and it broke my working trellis
installation.
You'll need to be more specific about "broke". ?Do you have a traceback?
PJ Eby
2011-10-24 16:48:29 UTC
Permalink
Post by nicky van foreest
Hi,
Thanks. I did not install trellis as an ubuntu package as it is not
available as a package. I used easy_install trellis. After the
problems occurred I reinstalled trellis with easy_install but the
problem of not being able to find Addons remains.
I notice that an Addons egg was in your easy-install.pth; is the egg file
actually there? What happens if you start a fresh Python interpreter and
import peak.util.addons?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20111024/d35dbc56/attachment.html
nicky van foreest
2011-10-24 19:59:43 UTC
Permalink
Post by PJ Eby
I notice that an Addons egg was in your easy-install.pth; is the egg file
actually there?
Yes:

***@chuck:~/lib/python$ ls
AddOns-0.7-py2.7.egg/ Contextual-0.7a1.dev_r2695-py2.7.egg/
DecoratorTools-1.8-py2.7.egg/ easy-install.pth
Extremes-1.1.1-py2.7.egg/ pulp.py* Pweave* pysparse-1.0.1/ site.py
site.pyc SymbolType-1.0-py2.7.egg/ tables@ tables-2.1.2/
Trellis-0.7a2-py2.7.egg/

?What happens if you start a fresh Python interpreter and
Post by PJ Eby
import peak.util.addons?
I started ipython:

In [1]: import peak.util.extremes
peak.util.extremes

it only autocompletes to peak.util.extremes. Pressing tab doesn't give
any other option for peak.util than extremes.
PJ Eby
2011-10-24 20:13:13 UTC
Permalink
Post by nicky van foreest
Post by PJ Eby
I notice that an Addons egg was in your easy-install.pth; is the egg file
actually there?
AddOns-0.7-py2.7.egg/ Contextual-0.7a1.dev_r2695-py2.7.egg/
DecoratorTools-1.8-py2.7.egg/ easy-install.pth
Extremes-1.1.1-py2.7.egg/ pulp.py* Pweave* pysparse-1.0.1/ site.py
Trellis-0.7a2-py2.7.egg/
What happens if you start a fresh Python interpreter and
Post by PJ Eby
import peak.util.addons?
In [1]: import peak.util.extremes
peak.util.extremes
it only autocompletes to peak.util.extremes. Pressing tab doesn't give
any other option for peak.util than extremes.
I didn't say IPython, I said a Python interpreter. I didn't ask about
autocompletion, I asked about importing.

This time, use regular Python, and actually try importing addons.
Post by nicky van foreest
Post by PJ Eby
Post by PJ Eby
import peak.util
print peak.util.__path__
My guess is that you now have a peak.util directory in your Ubuntu system
Python directory and it's not working properly with your current directory.
Post by nicky van foreest
Post by PJ Eby
Post by PJ Eby
import pkg_resources
pkg_resources.require('AddOns')
Then see if peak.util.__path__ then includes the AddOns egg, and whether
"import peak.util.addons" now works.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20111024/c05dd688/attachment.html
nicky van foreest
2011-10-24 20:38:33 UTC
Permalink
Sorry for my misunderstanding. This is the output:

***@chuck:~$ python
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named addons
Post by PJ Eby
Post by PJ Eby
import peak.util
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import pkg_resources
pkg_resources.require('AddOns')
[AddOns 0.7 (/home/nicky/lib/python/AddOns-0.7-py2.7.egg),
DecoratorTools 1.8
(/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg)]
Post by PJ Eby
Post by PJ Eby
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named addons
Post by PJ Eby
My guess is that you now have a peak.util directory in your Ubuntu system
Python directory and it's not working properly with your current directory.
I also checked whether my system contains any other peak.util
directory than the one in ~/lib/python , but this is not the case.
PJ Eby
2011-10-24 21:09:21 UTC
Permalink
Post by nicky van foreest
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
File "<stdin>", line 1, in <module>
ImportError: No module named addons
Post by PJ Eby
Post by PJ Eby
import peak.util
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import pkg_resources
pkg_resources.require('AddOns')
[AddOns 0.7 (/home/nicky/lib/python/AddOns-0.7-py2.7.egg),
DecoratorTools 1.8
(/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg)]
Post by PJ Eby
Post by PJ Eby
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
File "<stdin>", line 1, in <module>
ImportError: No module named addons
Post by PJ Eby
My guess is that you now have a peak.util directory in your Ubuntu system
Python directory and it's not working properly with your current
directory.
I also checked whether my system contains any other peak.util
directory than the one in ~/lib/python , but this is not the case.
Post by PJ Eby
pkg_resources.declare_namespace('peak.util')
Before the "require()" call, and see if peak.util.__path__ changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20111024/b3a2c1dc/attachment.html
nicky van foreest
2011-10-24 21:18:39 UTC
Permalink
Thanks for your support. I guess this is the right sequence:

***@chuck:~$ python
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
Post by PJ Eby
import peak.util
import pkg_resources
pkg_resources.declare_namespace('peak.util')
pkg_resources.require('AddOns')
[AddOns 0.7 (/home/nicky/lib/python/AddOns-0.7-py2.7.egg),
DecoratorTools 1.8
(/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg)]
Post by PJ Eby
Post by PJ Eby
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named addons
Post by PJ Eby
Python 2.7.2+ (default, Oct ?4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
?File "<stdin>", line 1, in <module>
ImportError: No module named addons
Post by PJ Eby
Post by PJ Eby
import peak.util
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import pkg_resources
pkg_resources.require('AddOns')
[AddOns 0.7 (/home/nicky/lib/python/AddOns-0.7-py2.7.egg),
DecoratorTools 1.8
(/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg)]
Post by PJ Eby
Post by PJ Eby
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
?File "<stdin>", line 1, in <module>
ImportError: No module named addons
Post by PJ Eby
My guess is that you now have a peak.util directory in your Ubuntu system
Python directory and it's not working properly with your current directory.
I also checked whether my system contains any other peak.util
directory than the one in ~/lib/python , but this is not the case.
Post by PJ Eby
pkg_resources.declare_namespace('peak.util')
Before the "require()" call, and see if peak.util.__path__ changes.
PJ Eby
2011-10-24 21:49:40 UTC
Permalink
Post by nicky van foreest
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
import peak.util
import pkg_resources
pkg_resources.declare_namespace('peak.util')
pkg_resources.require('AddOns')
[AddOns 0.7 (/home/nicky/lib/python/AddOns-0.7-py2.7.egg),
DecoratorTools 1.8
(/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg)]
Post by PJ Eby
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
import peak.util.addons
File "<stdin>", line 1, in <module>
ImportError: No module named addons
Ugh. Oh. Actually, I just thought of something. At the beginning, import
peak and then print peak.__path__ too. I think I may've missed something
there.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20111024/81dd43a7/attachment.html
nicky van foreest
2011-10-24 22:07:58 UTC
Permalink
Here is the output. It all looks well.

***@chuck:~$ python
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
import peak
print peak.__path__
['/home/nicky/lib/python/Trellis-0.7a2-py2.7.egg/peak',
'/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak',
'/home/nicky/lib/python/Contextual-0.7a1.dev_r2695-py2.7.egg/peak',
'/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg/peak',
'/home/nicky/lib/python/AddOns-0.7-py2.7.egg/peak',
'/home/nicky/lib/python/SymbolType-1.0-py2.7.egg/peak']
Python 2.7.2+ (default, Oct ?4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
Post by PJ Eby
import peak.util
import pkg_resources
pkg_resources.declare_namespace('peak.util')
pkg_resources.require('AddOns')
[AddOns 0.7 (/home/nicky/lib/python/AddOns-0.7-py2.7.egg),
DecoratorTools 1.8
(/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg)]
Post by PJ Eby
Post by PJ Eby
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
?File "<stdin>", line 1, in <module>
ImportError: No module named addons
Ugh. ?Oh. ?Actually, I just thought of something. ?At the beginning, import
peak and then print peak.__path__ ?too. ?I think I may've missed something
there.
PJ Eby
2011-10-24 23:06:13 UTC
Permalink
Post by nicky van foreest
Here is the output. It all looks well.
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
Post by nicky van foreest
Post by PJ Eby
import peak
print peak.__path__
['/home/nicky/lib/python/Trellis-0.7a2-py2.7.egg/peak',
'/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak',
'/home/nicky/lib/python/Contextual-0.7a1.dev_r2695-py2.7.egg/peak',
'/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg/peak',
'/home/nicky/lib/python/AddOns-0.7-py2.7.egg/peak',
'/home/nicky/lib/python/SymbolType-1.0-py2.7.egg/peak']
Indeed. So the question is why peak.util.__path__ only contains Extremes,
and not AddOns or DecoratorTools. Okay, try this:

import peak; import sys; print 'peak.util' in sys.modules

If it's in sys.modules before you explicitly import it, it's probably an
issue in the system python install, and you'll need to contact the Ubuntu
folks. It might also be a good idea to list all your system packages that
install stuff to the system Python, and to check what version of setuptools
or Distribute is installed, in case the issue is in the one that's installed
with the system Python.

My guess is that if you use an isolated virtualenv that doesn't use the
systemwide site-packages, this problem will go away. But that doesn't mean
it shouldn't be fixed.

(Note that even though you say there's no peak/util anywhere except in your
~lib/python, I strongly suspect that this has something to do with Debian
and Ubuntu distributing a "peak.util" package that contains a whole bunch of
peak.util stuff, with different versions of addons, decoratortools, etc.
jammed together.)
Post by nicky van foreest
Post by PJ Eby
Post by nicky van foreest
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Post by PJ Eby
Post by PJ Eby
import peak.util
import pkg_resources
pkg_resources.declare_namespace('peak.util')
pkg_resources.require('AddOns')
[AddOns 0.7 (/home/nicky/lib/python/AddOns-0.7-py2.7.egg),
DecoratorTools 1.8
(/home/nicky/lib/python/DecoratorTools-1.8-py2.7.egg)]
Post by PJ Eby
Post by PJ Eby
print peak.util.__path__
['/home/nicky/lib/python/Extremes-1.1.1-py2.7.egg/peak/util']
Post by PJ Eby
Post by PJ Eby
import peak.util.addons
File "<stdin>", line 1, in <module>
ImportError: No module named addons
Ugh. Oh. Actually, I just thought of something. At the beginning,
import
Post by PJ Eby
peak and then print peak.__path__ too. I think I may've missed
something
Post by PJ Eby
there.
_______________________________________________
PEAK mailing list
http://www.eby-sarna.com/mailman/listinfo/peak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.eby-sarna.com/pipermail/peak/attachments/20111024/45f6eadd/attachment.html
nicky van foreest
2011-10-25 20:21:34 UTC
Permalink
Indeed. ?So the question is why peak.util.__path__ only contains Extremes,
import peak; import sys; print 'peak.util' in sys.modules
This gives `False', as expected from your explanation below.
If it's in sys.modules before you explicitly import it, it's probably an
issue in the system python install, and you'll need to contact the Ubuntu
folks. ?It might also be a good idea to list all your system packages that
install stuff to the system Python, and to check what version of setuptools
or Distribute is installed, in case the issue is in the one that's installed
with the system Python.
To check this I decided to remove all the directories containing
Addons, etc., and reinstall with pip. At first I installed trellis
with pip into ~/lib/python, but this didn't result in a working
enviroment too. Then I decided to install trellis into the systemwide
site-packages, and now it works.
(Note that even though you say there's no peak/util anywhere except in your
~lib/python, I strongly suspect that this has something to do with Debian
and Ubuntu distributing a "peak.util" package that contains a whole bunch of
peak.util stuff, with different versions of addons, decoratortools, etc.
jammed together.)
I am pretty sure this is not the case. I used locate peak |grep util
to find any file on the system that matches peak and util (and I
updated the database used by locate to ensure it was refreshed). The
only ones were in ~/lib/python.

Thanks very much for all your help.

Loading...