scipy, matplotlib import errors

Hello, could someone please help me understand a strange problem, possibly associated with PYTHONPATH. When I import matplotlib, pylab, or scipy from any directory other than the root installation directory, it fails. However, if I’m in the python installation directory there are no errors. Thanks in advance! Please see below:
[jfb@…1957… ~]$ python
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import scipy
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/python2.5/site-packages/scipy/init.py”, line 18, in
import pkg_resources as _pr # activate namespace packages (manipulates path)
File “/usr/lib/python2.5/site-packages/pkg_resources.py”, line 2581, in
add_activation_listener(lambda dist: dist.activate())
File “/usr/lib/python2.5/site-packages/pkg_resources.py”, line 640, in subscribe
callback(dist)
File “/usr/lib/python2.5/site-packages/pkg_resources.py”, line 2581, in
add_activation_listener(lambda dist: dist.activate())
File “/usr/lib/python2.5/site-packages/pkg_resources.py”, line 2130, in activate
map(declare_namespace, self._get_metadata(‘namespace_packages.txt’))
File “/usr/lib/python2.5/site-packages/pkg_resources.py”, line 1749, in declare_namespace
_handle_ns(packageName, path_item)
File “/usr/lib/python2.5/site-packages/pkg_resources.py”, line 1712, in _handle_ns
module = sys.modules[packageName] = new.module(packageName)
AttributeError: ‘module’ object has no attribute ‘module’

[jfb@…1957… ~] cd /usr/lib/python2.5/ [jfb@...1957... python2.5] python
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import scipy

[jfb@…1957… python2.5] cd [jfb@...1957... ~] echo PYTHONPATH** :.:/usr/lib/python2.5/:.:/home/jfb/bin **[jfb@...1957... ~]

John wrote:

Hello, could someone please help me understand a strange problem, possibly associated with PYTHONPATH. When I import matplotlib, pylab, or scipy from any directory other than the root installation directory, it fails. However, if I'm in the python installation directory there are no errors. Thanks in advance! Please see below:

*[jfb@...1957... ~]$ python*
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/scipy/__init__.py", line 18, in <module>
    import pkg_resources as _pr # activate namespace packages (manipulates __path__)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2581, in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 640, in subscribe
    callback(dist)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2581, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2130, in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1749, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1712, in _handle_ns
    module = sys.modules[packageName] = new.module(packageName)
AttributeError: 'module' object has no attribute 'module'

You have a new.py module somewhere which is interfering with the standard library's "new" module. Find it and rename it.

···

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

Thank you!

I see this is a deprecated module, might I break something else?

Thanks again,
john

Robert Kern-2 wrote:

···

John wrote:

Hello, could someone please help me understand a strange problem,
possibly associated with PYTHONPATH. When I import matplotlib, pylab, or
scipy from any directory other than the root installation directory, it
fails. However, if I'm in the python installation directory there are no
errors. Thanks in advance! Please see below:

*[jfb@...1957... ~]$ python*
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/scipy/__init__.py", line 18, in
<module>
    import pkg_resources as _pr # activate namespace packages
(manipulates __path__)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2581,
in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 640, in
subscribe
    callback(dist)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2581,
in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2130,
in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1749,
in declare_namespace
    _handle_ns(packageName, path_item)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1712,
in _handle_ns
    module = sys.modules[packageName] = new.module(packageName)
AttributeError: 'module' object has no attribute 'module'

You have a new.py module somewhere which is interfering with the standard
library's "new" module. Find it and rename it.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma
  that is made terrible by our own mad attempt to interpret it as though
it had
  an underlying truth."
   -- Umberto Eco

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
View this message in context: http://www.nabble.com/scipy%2C-matplotlib-import-errors-tp16343711p19678674.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I wonder if I've misunderstood or made a mistake? I renamed a file:
/usr/lib/python2.5/new.py to /usr/lib/python2.5/new.bak

and everything worked... but now, after logging out and logging back in
again, I'm getting the problem again?

Perhaps that was the standard libraries module? But I cannot find any other
new.py files?

Thanks,
john

Robert Kern-2 wrote:

···

John wrote:

Hello, could someone please help me understand a strange problem,
possibly associated with PYTHONPATH. When I import matplotlib, pylab, or
scipy from any directory other than the root installation directory, it
fails. However, if I'm in the python installation directory there are no
errors. Thanks in advance! Please see below:

*[jfb@...1957... ~]$ python*
Python 2.5.1 (r251:54863, Mar 7 2008, 04:10:12)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/scipy/__init__.py", line 18, in
<module>
    import pkg_resources as _pr # activate namespace packages
(manipulates __path__)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2581,
in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 640, in
subscribe
    callback(dist)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2581,
in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 2130,
in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1749,
in declare_namespace
    _handle_ns(packageName, path_item)
  File "/usr/lib/python2.5/site-packages/pkg_resources.py", line 1712,
in _handle_ns
    module = sys.modules[packageName] = new.module(packageName)
AttributeError: 'module' object has no attribute 'module'

You have a new.py module somewhere which is interfering with the standard
library's "new" module. Find it and rename it.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma
  that is made terrible by our own mad attempt to interpret it as though
it had
  an underlying truth."
   -- Umberto Eco

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
View this message in context: http://www.nabble.com/scipy%2C-matplotlib-import-errors-tp16343711p19679575.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

I'm revisiting this with a new round of errors. I keep getting this error,
maybe related as before to the 'new' module, but I cannot tell?? Does anyone
know what is going on?

Python 2.5.1 (r251:54863, Jun 15 2008, 18:24:51)
[GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pylab

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/pylab.py", line 1, in <module>
    from matplotlib.pylab import *
  File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 128,
in <module>
    from rcsetup import defaultParams, validate_backend, validate_toolbar
  File "/usr/lib/python2.5/site-packages/matplotlib/rcsetup.py", line 19, in
<module>
    from matplotlib.colors import is_color_like
  File "/usr/lib/python2.5/site-packages/matplotlib/colors.py", line 39, in
<module>
    import matplotlib.cbook as cbook
  File "/usr/lib/python2.5/site-packages/matplotlib/cbook.py", line 16, in
<module>
    preferredencoding = locale.getpreferredencoding()
  File "/usr/lib/python2.5/locale.py", line 512, in getpreferredencoding
    setlocale(LC_CTYPE, "")
  File "/usr/lib/python2.5/locale.py", line 476, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

···

--
View this message in context: http://www.nabble.com/scipy%2C-matplotlib-import-errors-tp16343711p19679786.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

John [H2O] wrote:

I wonder if I've misunderstood or made a mistake? I renamed a file:
/usr/lib/python2.5/new.py to /usr/lib/python2.5/new.bak

and everything worked... but now, after logging out and logging back in
again, I'm getting the problem again?

Perhaps that was the standard libraries module? But I cannot find any other
new.py files?

/usr/lib/python2.5/new.py is the standard library's module. Leave it alone. If you are still having problems and cannot find another new.py module anywhere, edit pkg_resources.py to print out new.__file__ just before where the exception occurs.

···

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

Thanks.

I haven't done this yet, but I think the problem may have been related to my
locales setting. Presently all is working after editing /etc/sysconfig/i18n
to update LC_CTYPE and other variables.

Robert Kern-2 wrote:

···

John [H2O] wrote:

I wonder if I've misunderstood or made a mistake? I renamed a file:
/usr/lib/python2.5/new.py to /usr/lib/python2.5/new.bak

and everything worked... but now, after logging out and logging back in
again, I'm getting the problem again?

Perhaps that was the standard libraries module? But I cannot find any
other
new.py files?

/usr/lib/python2.5/new.py is the standard library's module. Leave it
alone. If
you are still having problems and cannot find another new.py module
anywhere,
edit pkg_resources.py to print out new.__file__ just before where the
exception
occurs.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma
  that is made terrible by our own mad attempt to interpret it as though
it had
  an underlying truth."
   -- Umberto Eco

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
View this message in context: http://www.nabble.com/scipy%2C-matplotlib-import-errors-tp16343711p19701831.html
Sent from the matplotlib - users mailing list archive at Nabble.com.