was trying to install pylons on a linux box running suse, having python
2.5.2. I chose to try and install it "normally", i.e. without a py virtual
env. I tred to follow the instructions in the pylonsbook, however, the last
command below gives the indicated error:
$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ python ez_setup.py
Setuptools version 0.6c8 or greater has been installed.
(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)
$ sudo python ez_setup.py -U setuptools
Searching for setuptools
Reading http://pypi.python.org/simple/setuptools/
Best match: setuptools 0.6c8
Processing setuptools-0.6c8-py2.5.egg
setuptools 0.6c8 is already the active version in easy-install.pth
Installing easy_install script to /usr/local/bin
Installing easy_install-2.5 script to /usr/local/bin
Using /usr/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg
Processing dependencies for setuptools
Finished processing dependencies for setuptools
$ easy_install PasteDeploy
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
First of all, is this the correct install procedure?
What is the issue with this missing pgk_resources?
Where do I get it from?
Thanks! mario
pkg_resources is part of setuptools. That suggests something is wrong
with the Python path and it's not finding any of the new packages.
Did you install Python to /usr/local or are you using the system
Python? The standard Python in Debian/Ubuntu is specially configured
to look for packages in /usr/local/lib/python2.5/site-packages, but I
don't know if Suse does this.
Do you have multiple copies of Python installed? If so you have to
make sure you're using the same copy for ez_setup.py, easy_install,
python, and paster; e.g., watch out for the shell defaulting to a
different one.
Do you have a custom distutils.cfg or ~/.pydistutils.cfg? It's
possible to configure easy_install to install packages to a directory
where Python can't see them. In that case you either have to change
your install location or make a *.pth file that does "import site;
site.addsitedir('/the/directory/easy_install/is/installing/into')".
--
Mike Orr <slugg...@gmail.com>
Yes in installed 2.5.2 to /usr/local :
$ which python
/usr/local/bin/python
$ python
Python 2.5.2 (r252:60911, Jul 8 2008, 17:38:14)
[GCC 4.1.2 20070115 (prerelease) (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Yes, there was (still is, but unused afaict) :
$ /usr/bin/python
Python 2.4.2 (#1, Apr 13 2007, 15:45:45)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
> Do you have multiple copies of Python installed? If so you have to
> make sure you're using the same copy for ez_setup.py, easy_install,
> python, and paster; e.g., watch out for the shell defaulting to a
> different one.
Starting new shells gives 2.5.2. How do i easily make make sure that all
those are also using 2.5.2?
> Do you have a custom distutils.cfg or ~/.pydistutils.cfg?
No. Doing:
$ sudo find / | grep -i distutils
only gives results for files under:
/usr/local/lib/python2.5/distutils/...
> It's
> possible to configure easy_install to install packages to a directory
> where Python can't see them. In that case you either have to change
> your install location or make a *.pth file that does "import site;
> site.addsitedir('/the/directory/easy_install/is/installing/into')".
OK, i made /usr/local/lib/python2.5/site-packages/ez-hack.pth :
import site; site.addsitedir('/usr/local/lib/python2.5/site-packages')
But then:
$ python ez_setup.py
'import site' failed; use -v for traceback
Setuptools version 0.6c8 or greater has been installed.
(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)
Ane the error is a:
RuntimeError: maximum recursion depth exceeded
Note that there is also this file:
$ cat /usr/local/lib/python2.5/site-packages/easy-install.pth
import sys; sys.__plen = len(sys.path)
./setuptools-0.6c8-py2.5.egg
./Durus-3.7-py2.5-linux-i686.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)
Thanks... mario
> --
> Mike Orr <slugg...@gmail.com>
Yes. From within that directory you're importing that directory - that
explains the recursion. If you're getting this error I'd say means
that you're using the right Python and it's looking in the right
place.
Are you running easy_install as root?
--
Raoul Snyman
B.Tech Information Technology (Software Engineering)
E-Mail: raoul....@gmail.com
Web: http://www.saturnlaboratories.co.za/
Blog: http://blog.saturnlaboratories.co.za/
Mobile: 082 550 3754
Registered Linux User #333298 (http://counter.li.org)
Theoretically you change the PATH in ~/.profile or ~/.bashrc.
However, if you're using Konsole I've noticed it sometimes ignores
those when opening new tabs. So you may have to fuss a bit. But by
running 'which' and typing the full path when you notice it outputing
the wrong one, eventually you'll see the pattern on your system.
Note that it's not *versions* of Python but *copies* of Python. There
can be multiple copies with the same version, and each has its own
site-packages directory and its own notion of other site directories.
>> Do you have a custom distutils.cfg or ~/.pydistutils.cfg?
>
> No. Doing:
> $ sudo find / | grep -i distutils
> only gives results for files under:
> /usr/local/lib/python2.5/distutils/...
That's the standard distutils.cfg though you might have customized it.
> OK, i made /usr/local/lib/python2.5/site-packages/ez-hack.pth :
> import site; site.addsitedir('/usr/local/lib/python2.5/site-packages')
As Raoul said, that's recursive. The point is to add a site dir that
Python wouldn't normally look at otherwise. I was thinking of
/usr/lib/python2.5/site-packages ->
/usr/local/lib/python2.5/site-packages, but if you've installed Python
manually to /usr/local, that wouldn't be appropriate.
--
Mike Orr <slugg...@gmail.com>
I ssh into the box, and it seems that /usr/local/bin should be picked up
before /usr/bin :
$ echo $PATH
/home/mario/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/opt/gnome/bin:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin
> Note that it's not *versions* of Python but *copies* of Python. There
> can be multiple copies with the same version, and each has its own
> site-packages directory and its own notion of other site directories.
/usr/local/bin had two identical copies of the python executable (is this
potentailly problematic?). I removed "python" and did:
$ pwd
/usr/local/bin
$ sudo ln -s python2.5 python
>>> Do you have a custom distutils.cfg or ~/.pydistutils.cfg?
>>
>> No. Doing:
>> $ sudo find / | grep -i distutils
>> only gives results for files under:
>> /usr/local/lib/python2.5/distutils/...
>
> That's the standard distutils.cfg though you might have customized it.
OK, now I saw the note on the installation page so I added the 2-line file
(there was no .cfg anywhere):
/usr/local/lib/python2.5/distutils/distutils.cfg
[easy_install]
zip_ok = 0
>> OK, i made /usr/local/lib/python2.5/site-packages/ez-hack.pth :
>> import site; site.addsitedir('/usr/local/lib/python2.5/site-packages')
>
> As Raoul said, that's recursive. The point is to add a site dir that
> Python wouldn't normally look at otherwise. I was thinking of
> /usr/lib/python2.5/site-packages ->
> /usr/local/lib/python2.5/site-packages, but if you've installed Python
> manually to /usr/local, that wouldn't be appropriate.
I removed this file now. And, to also answer Raoul, i tried both as root
and as not. The error is still there after the above changes:
> sudo easy_install PasteDeploy
root's password:
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in ?
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
mario
> --
> Mike Orr <slugg...@gmail.com>
OK, two *compilations* then. The installation process creates a
"python" executable identical to "python2.5" unless you set some
option to suppress it.
>>> /usr/local/lib/python2.5/distutils/...
>>
>> That's the standard distutils.cfg though you might have customized it.
>
> OK, now I saw the note on the installation page so I added the 2-line file
> (there was no .cfg anywhere):
> /usr/local/lib/python2.5/distutils/distutils.cfg
> [easy_install]
> zip_ok = 0
That's what I use, but it won't affect this problem.
> I removed this file now. And, to also answer Raoul, i tried both as root
> and as not. The error is still there after the above changes:
>
>> sudo easy_install PasteDeploy
> root's password:
> Traceback (most recent call last):
> File "/usr/local/bin/easy_install", line 5, in ?
> from pkg_resources import load_entry_point
> ImportError: No module named pkg_resources
So, we need to see the Python path at this point. Sometimes you can
get a debugger prompt with easy_install, and sometimes not. Try:
==
$ sudo /usr/local/bin/python2.5 -m pdb /usr/local/bin/easy_install PasteDeploy
(pdb) c
...
ImportError: no module named pkg_resources
(pdb) import sys, print
(pdb) pprint.pprint(sys.path)
(pdb) import setuptools
...
ImportError: no module named setuptools
- Or if it does find Setuptools -
(pdb) setupotools
<module 'setuptools' from '-some path->
==
If Python just exits after the error rather than giving a pdb prompt,
you can try "python -i":
==
$ sudo /usr/local/bin/python2.5 -i /usr/local/bin/easy_install PasteDeploy
...
ImportError: no module named pkg_resources
>>> import pdb
>>> pdb.pm()
(pdb) import sys, pprint
(pdb) pprint.pprint(sys.path)
==
That also may or may not give you a pdb prompt depending on something
in Python I haven't figured out, but it's an alternative.
You can also try importing other expected modules to see if nothing in
the directory imports, or only pkg_resources.
--
Mike Orr <slugg...@gmail.com>
> So, we need to see the Python path at this point. Sometimes you can
> get a debugger prompt with easy_install, and sometimes not. Try:
>
> ==
> $ sudo /usr/local/bin/python2.5 -m pdb /usr/local/bin/easy_install
> PasteDeploy
> (pdb) c
> ...
> ImportError: no module named pkg_resources
> (pdb) import sys, print
> (pdb) pprint.pprint(sys.path)
> (pdb) import setuptools
> ...
> ImportError: no module named setuptools
> - Or if it does find Setuptools -
> (pdb) setupotools
> <module 'setuptools' from '-some path->
> ==
OK, interesting stuff, if somewhat magical.
I tried as you suggest, here's the transcript:
----
$ sudo /usr/local/bin/python2.5 -m pdb /usr/local/bin/easy_install
PasteDeploy
> /usr/local/bin/easy_install(3)<module>()
-> __requires__ = 'setuptools==0.6c8'
(Pdb) c
Searching for PasteDeploy
Reading http://pypi.python.org/simple/PasteDeploy/
Reading http://pythonpaste.org/deploy/
Reading http://pythonpaste.org/deploy/paste-deploy.html
Best match: PasteDeploy 1.3.2
Downloading
http://pypi.python.org/packages/source/P/PasteDeploy/PasteDeploy-1.3.2.tar.gz#md5=877fcf3fa025a65147f\
bae87e1765b65
Processing PasteDeploy-1.3.2.tar.gz
Running PasteDeploy-1.3.2/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-UaOA_8/PasteDeploy-1.3.2/egg-dist-tmp-mDVyJI
warning: no files found matching 'docs/*.html'
warning: no previously-included files found matching 'docs/rebuild'
Adding PasteDeploy 1.3.2 to easy-install.pth file
Installed
/usr/local/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg
Processing dependencies for PasteDeploy
Finished processing dependencies for PasteDeploy
The program exited via sys.exit(). Exit status:
> /usr/local/bin/easy_install(3)<module>()
-> __requires__ = 'setuptools==0.6c8'
(Pdb) setuptools
*** NameError: name 'setuptools' is not defined
(Pdb) import setuptools
(Pdb) setuptools
<module 'setuptools' from
'/usr/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/setuptools/__init__.pyc'>
(Pdb) import sys, pprint
(Pdb) pprint.pprint(sys.path)
['/usr/local/bin',
'/usr/local/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg',
'/usr/local/lib/python2.5/site-packages/Durus-3.7-py2.5-linux-i686.egg',
'/usr/local/lib/python2.5/site-packages/PasteDeploy-1.3.2-py2.5.egg',
'/usr/local/lib/python25.zip',
'/usr/local/lib/python2.5',
'/usr/local/lib/python2.5/plat-linux2',
'/usr/local/lib/python2.5/lib-tk',
'/usr/local/lib/python2.5/lib-dynload',
'/usr/local/lib/python2.5/site-packages',
'/usr/local/lib/python2.5/site-packages/PIL',
'/home/mario/py_packages']
(Pdb)
Post mortem debugger finished. The /usr/local/bin/easy_install will be
restarted
> /usr/local/bin/easy_install(3)<module>()
-> __requires__ = 'setuptools==0.6c8'
(Pdb) from pkg_resources import load_entry_point
(Pdb)
----
How should I interpret this ?!?
Other than that by the end it works !!
The sweet corollary of this is that:
$ sudo easy_install Pylons
Searching for Pylons
Reading http://pypi.python.org/simple/Pylons/
...
also installs with no errors ;-)
But, there is yet another snag, for this project to fly -- altho it really
has nothing to do with pylons directly. Imposed is a mysql db instance. I
need to install mysql-python... however:
$ sudo easy_install mysql-python
Searching for mysql-python
Reading http://pypi.python.org/simple/mysql-python/
Couldn't find index page for 'mysql-python' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading http://pypi.python.org/simple/
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python
Reading http://sourceforge.net/projects/mysql-python/
Best match: MySQL-python 1.2.2
Downloading
http://internap.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
Processing MySQL-python-1.2.2.tar.gz
Running MySQL-python-1.2.2/setup.py -q bdist_egg --dist-dir
/tmp/easy_install-AGmMiF/MySQL-python-1.2.2/egg-dist-tmp-xjAM19
sh: mysql_config: command not found
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 8, in <module>
load_entry_point('setuptools==0.6c8', 'console_scripts',
'easy_install')()
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1671, in main
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1659, in with_ei_usage
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 1675, in <lambda>
File "/usr/local/lib/python2.5/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/local/lib/python2.5/distutils/dist.py", line 974, in
run_commands
self.run_command(cmd)
File "/usr/local/lib/python2.5/distutils/dist.py", line 994, in
run_command
cmd_obj.run()
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 211, in run
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 446, in easy_install
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 476, in install_item
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 655, in install_eggs
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 930, in build_and_install
File "build/bdist.linux-i686/egg/setuptools/command/easy_install.py",
line 919, in run_setup
File "build/bdist.linux-i686/egg/setuptools/sandbox.py", line 27, in
run_setup
File "build/bdist.linux-i686/egg/setuptools/sandbox.py", line 63, in run
File "build/bdist.linux-i686/egg/setuptools/sandbox.py", line 29, in
<lambda>
File "setup.py", line 16, in <module>
File "/tmp/easy_install-AGmMiF/MySQL-python-1.2.2/setup_posix.py", line
43, in get_config
File "/tmp/easy_install-AGmMiF/MySQL-python-1.2.2/setup_posix.py", line
24, in mysql_config
EnvironmentError: mysql_config not found
Any one has any insight into this problem? (Ouch, I am really pressed for
time, had not foreseen such problems with installation of python packages!)
Thanks a lot! mario
> --
> Mike Orr <slugg...@gmail.com>
It's standard Python troubleshooting techniques, so worth keeping in
your wallet for when you need them.
Your Python path includes /usr/local/lib/python2.5/site-packages as it
should, and paths for the eggs you want are before paths for any
conflicting eggs you don't want. "/usr/local/bin" would not normally
be in sys.path but I assume that was the current directory at the
time. That "/home/mario/py_packages" must have come from PYTHONPATH
or a *.pth file. Whenever you have packages not found or the wrong
version, remember to look there to see if it contains any overlapping
eggs that may have contributed to the problem.
I don't know why it's suddenly working now but it suggests something
was wrong in your last shell session. Sometimes those are not
reproduceable.
> $ sudo easy_install mysql-python
...
> File "/tmp/easy_install-AGmMiF/MySQL-python-1.2.2/setup_posix.py", line
> 24, in mysql_config
> EnvironmentError: mysql_config not found
>
> Any one has any insight into this problem? (Ouch, I am really pressed for
> time, had not foreseen such problems with installation of python packages!)
I use the Ubuntu package (python-mysqldb) to avoid that problem.
Either you didn't install MySQL's development files, or Python can't
find them, or there's some mysql command it can't run. Things like
that always happen when installing pacakges with C extensions. I used
to have lots of trouble getting PIL to compile on some systems.
--
Mike Orr <slugg...@gmail.com>
Certainly. The "magical" ref was to the fact that it suddenly works just by
running the debugger on it... but of course it is probably for another
reason, like some problem in the shell session as you suggest.
> Your Python path includes /usr/local/lib/python2.5/site-packages as it
> should, and paths for the eggs you want are before paths for any
> conflicting eggs you don't want. "/usr/local/bin" would not normally
> be in sys.path but I assume that was the current directory at the
> time.
If i dump sys.path it is not...
> That "/home/mario/py_packages" must have come from PYTHONPATH
> or a *.pth file. Whenever you have packages not found or the wrong
> version, remember to look there to see if it contains any overlapping
> eggs that may have contributed to the problem.
From a pth file... to my dev area, where I have packages that i work with
directly on svn, just for convenience. I never install 3rp party packages
there.
>> $ sudo easy_install mysql-python
>> EnvironmentError: mysql_config not found
> I use the Ubuntu package (python-mysqldb) to avoid that problem.
> Either you didn't install MySQL's development files, or Python can't
> find them, or there's some mysql command it can't run. Things like
> that always happen when installing pacakges with C extensions. I used
> to have lots of trouble getting PIL to compile on some systems.
I was not aware that I could use a Ubuntu package instead! Anyhow, after
some frustration i realized i need mysql-devel package, so i fished around
for what seems to be the latest version for the platform, and then to
install it, like so:
wget
ftp://rpmfind.net/linux/SuSE-Linux/i386/update/10.2/rpm/i586/mysql-devel-***.rpm
sudo rpm -i mysql-devel-5.0.26-16.i586.rpm
Yes, I recently also had some trouble to install PIL with jpg support on
the same Suse machine as well as on a Mac OS X laptop.
First experiences with pylons seem to be a lot less frustrating ;-)
Thanks a lot for your help!