how to reference the right python

General discussions related to Python.

Moderators: KDoiron, ChrJim, mawe, python

how to reference the right python

Postby CryingSaul on Mon Jan 19, 2009 2:29 pm

hi,

i managed to get a working setup of python 2.6.1 + ipython on my ubuntu 8.10 system by installing from source using the following command:

Code: Select all
./configure --prefix=/usr/local --with-zlib=/path/to/source/zlib-1.2.3 --with-readline=/path/to/source/readline-5.2


i did this so as to avoid overwriting python 2.5 files needed for ubuntu to function properly. everything about python itself has been working well since then, the interpreter, ipython, and even numpy (installed with the same --prefix).

now i wanted to install scribes, a gnome text editor. i tried it through synaptic but when i launched the newly installed app, nothing happened. so i removed it and tried installing from source. here's what i got after typing './configure':

Code: Select all
checking for a Python interpreter with version >= 2.5... python
checking for python... /usr/local/bin/python
checking for python version... 2.6
checking for python platform... linux2
checking for python script directory... ${prefix}/lib/python2.6/site-packages
checking for python extension module directory... ${exec_prefix}/lib/python2.6/site-packages
Error: Python bindings for D-Bus was not found.
configure: error: Error: Dependency check failed


apparently the configuration is finding my 2.6.1 in /usr/local instead of the 2.5 which it needs for its dependencies. i tried different --prefix= switches but none worked.

typing 'which python' in terminal says '/usr/local/bin/python'. apparently this is what ./configure checks in order to find python. my /usr/local/bin folder comes before /usr/bin in my PATH variable. so i did this:

Code: Select all
PATH=/usr/bin:$PATH


and tried again. now the ./configure command completes successfully (detecting python 2.5) but the 'make' command fails, saying:

Code: Select all
Making all in po
make[1]: Entering directory `/path/to/source/scribes-0.3.3.3/po'
file=`echo de | sed 's,.*/,,'`.gmo \
     && rm -f $file &&  -o $file de.po
/bin/sh: -o: not found
make[1]: *** [de.gmo] Error 127
make[1]: Leaving directory `/path/to/source/scribes-0.3.3.3/po'
make: *** [all-recursive] Error 1


i don't need any other app installed except scribes, but still it seems that both python versions have trouble coexisting, i.e. the very reason why i installed 2.6.1 in /usr/local in the first place is actually causing its share of havoc.

i tried removing and reinstalling scribes through apt-get and aptitude but scribes still wouldn't launch. any other app that i've installed prior to installing python 2.6.1 (e.g. geany, vlc) is doing perfectly alright.

any pointers?

thanks.
CryingSaul
New Python User
New Python User
 
Posts: 27
Joined: Wed Dec 10, 2008 12:49 am

Re: how to reference the right python

Postby Wacky on Mon Jan 19, 2009 4:04 pm

Hi again. (:

CryingSaul wrote:now i wanted to install scribes, a gnome text editor. i tried it through synaptic but when i launched the newly installed app, nothing happened. so i removed it and tried installing from source. here's what i got after typing './configure':

Code: Select all
checking for a Python interpreter with version >= 2.5... python
checking for python... /usr/local/bin/python
checking for python version... 2.6
checking for python platform... linux2
checking for python script directory... ${prefix}/lib/python2.6/site-packages
checking for python extension module directory... ${exec_prefix}/lib/python2.6/site-packages
Error: Python bindings for D-Bus was not found.
configure: error: Error: Dependency check failed


apparently the configuration is finding my 2.6.1 in /usr/local instead of the 2.5 which it needs for its dependencies. i tried different --prefix= switches but none worked.

I think that the "--prefix=" will only affect where Scribes is installed to, not where it looks for things. I might be wrong.

It looks more like you need to add D-Bus goodies to Python 2.6 (somehow; I'm Googling now) to get it to play nicely.

typing 'which python' in terminal says '/usr/local/bin/python'. apparently this is what ./configure checks in order to find python. my /usr/local/bin folder comes before /usr/bin in my PATH variable. so i did this:

Code: Select all
PATH=/usr/bin:$PATH


and tried again. now the ./configure command completes successfully (detecting python 2.5) but the 'make' command fails, saying:

Code: Select all
Making all in po
make[1]: Entering directory `/path/to/source/scribes-0.3.3.3/po'
file=`echo de | sed 's,.*/,,'`.gmo \
     && rm -f $file &&  -o $file de.po
/bin/sh: -o: not found
make[1]: *** [de.gmo] Error 127
make[1]: Leaving directory `/path/to/source/scribes-0.3.3.3/po'
make: *** [all-recursive] Error 1

That looks broken...

This bit makes sense:

Code: Select all
file=`echo de | sed 's,.*/,,'`.gmo \
     && rm -f $file &&  -o $file de.po
/bin/sh: -o: not found

...because the "&&"s separate commands, and there's (usually) no "-o" program, so effectively running this:

Code: Select all
user@host:~$ -o filename.gmo de.po

...would cause an error. The shell code in your output look broken, in short. The program that "-o (...etc.)" is supposed to be passed to seems not to be referenced in it.

I'm not sure what to suggest now, but I'll post back if I find anything. :?
The plus sign (+) is valid within an email address; please do not
write or suggest code that precludes its use, as many use it as a
"label" to filter incoming mail. </crusade> (Eek! Heresy, Imagist! ;))
Wacky
Python Guru
Python Guru
 
Posts: 673
Joined: Fri Aug 29, 2008 10:40 am
Location: EU

Re: how to reference the right python

Postby CryingSaul on Tue Jan 20, 2009 12:02 am

scribe's author has kindly responded to a mail i sent him (or her) with the following:

Your OS should provide a way to set the default python version you
want to use. Also try reinstalling Dbus- python to see if this fixes
your problem.


the second remark suggests the same thing you did, wacky, however it's the first sentence that i'd like to look into. i know for a fact that scribes would have installed nicely if i hadn't installed python 2.6.1 (i tried it during my many re-installations of ubuntu when i first embarked on this annoying adventure). what i was hoping to do is make the installer ignore my 2.6.1 setup which, as you remember, i put in /usr/local specifically for that purpose.

so, is there a way for ubuntu to "set the default python version"?

thanks again.
CryingSaul
New Python User
New Python User
 
Posts: 27
Joined: Wed Dec 10, 2008 12:49 am

Re: how to reference the right python

Postby CryingSaul on Tue Jan 20, 2009 12:22 am

the nightmare continues. reinstalling python-dbus in synaptic doesn't help, trying to remove it for a new install has synaptic proposing the removal of around 30 packages... doing a ./configure from source (for d-bus) gives this:

Code: Select all
checking for DBUS... configure: error: Package requirements (dbus-1 >= 1.0) were not met:

No package 'dbus-1' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables DBUS_CFLAGS
and DBUS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.


i found this via google:

Ubuntu automatically installs python 2.5 and uses it as the default python … I have crashed my system 2 times to solve this .. I wanted to make the default python to version 2.4.
First, edit the /usr/share/python/debian_defaults, changing the default version arg to python2.4

2nd,

$ sudo mv /usr/bin/python /usr/bin/python25
$ sudo ln -s /usr/bin/python2.4 /usr/bin/python


i checked the debian_defaults, which all point to 2.5. doing 'ls -l py*' in /usr/bin show all symbolic links pointing to the python2.5 directory. everything seems ok.

all i wanted was to install a text editor. the efforts by the linux community to portray the os as user-friendly seem less and less convincing :)

in one word: help!
CryingSaul
New Python User
New Python User
 
Posts: 27
Joined: Wed Dec 10, 2008 12:49 am

Re: how to reference the right python

Postby Wacky on Tue Jan 20, 2009 1:23 pm

CryingSaul wrote:scribe's author has kindly responded to a mail i sent him (or her) with the following:

Your OS should provide a way to set the default python version you
want to use. Also try reinstalling Dbus- python to see if this fixes
your problem.

That was nice of him/her. (:

the second remark suggests the same thing you did, wacky, however it's the first sentence that i'd like to look into. i know for a fact that scribes would have installed nicely if i hadn't installed python 2.6.1 (i tried it during my many re-installations of ubuntu when i first embarked on this annoying adventure). what i was hoping to do is make the installer ignore my 2.6.1 setup which, as you remember, i put in /usr/local specifically for that purpose.

so, is there a way for ubuntu to "set the default python version"?

Yes, but the method might depend on what state your system is in... :D

Whatever comes first in your path, and after that whatever /usr/bin/python points to, should be the "default". The latter is the "system Python version", though; I think many Python programs use "#!/usr/bin/python".

CryingSaul wrote:the nightmare continues. reinstalling python-dbus in synaptic doesn't help, trying to remove it for a new install has synaptic proposing the removal of around 30 packages... doing a ./configure from source (for d-bus) gives this:

Code: Select all
checking for DBUS... configure: error: Package requirements (dbus-1 >= 1.0) were not met:

No package 'dbus-1' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables DBUS_CFLAGS
and DBUS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

I'm afraid that I have no ideas for that. :?

i found this via google:

Ubuntu automatically installs python 2.5 and uses it as the default python … I have crashed my system 2 times to solve this .. I wanted to make the default python to version 2.4.
First, edit the /usr/share/python/debian_defaults, changing the default version arg to python2.4

2nd,

$ sudo mv /usr/bin/python /usr/bin/python25
$ sudo ln -s /usr/bin/python2.4 /usr/bin/python


i checked the debian_defaults, which all point to 2.5. doing 'ls -l py*' in /usr/bin show all symbolic links pointing to the python2.5 directory. everything seems ok.

Hmm. If you installed the editor from source, it should either use whatever your "which python" is, or /usr/bin/python; if you make sure that "which python" is Python 2.5 (or whichever version is required), then I can't think of a reason off-hand why it wouldn't work. :(

all i wanted was to install a text editor. the efforts by the linux community to portray the os as user-friendly seem less and less convincing :)

To be fair, Linux these days is usually quite user-friendly, provided that you don't play with its innards -- just like Windows. :mrgreen: And fixing problems is usually easier than in Windows, due both to better availability of bug documentation, and an experienced and helpful community. But Linux and Windows should be used for different things, of course. Right tool for the job, and all that. Windows is a hammer, Linux is a Swiss Army Knife. :mrgreen:
The plus sign (+) is valid within an email address; please do not
write or suggest code that precludes its use, as many use it as a
"label" to filter incoming mail. </crusade> (Eek! Heresy, Imagist! ;))
Wacky
Python Guru
Python Guru
 
Posts: 673
Joined: Fri Aug 29, 2008 10:40 am
Location: EU

Re: how to reference the right python

Postby CryingSaul on Tue Jan 20, 2009 2:50 pm

thank you for your answers. i'm afraid everything has gone downhill in a sort of snowball effect, with aptitude reporting around 30 unfixable broken packages and ipython suddenly unable to find readline. that os has gone to meet its maker and joined the bleeding choir invisible. i am currently reinstalling the whole system and trying to do something different, from scratch. i'll post if i find something useful. the tutorial will have to wait: )

for information, i found a post on the ubuntu forums saying:

My advise [sic] would be: don't upgrade Python if you are not ready to solve any problems with dependencies. many of your programs depend on Python and if you change it, something might go wrong.

Much safer choice is to wait until stock Python in ubuntu will be 2.6.


as to the zlib/readline problem, there's a very detailed explanation of which dependencies needs to be installed without going through the whole --with syntax. the instructions are for hardy but it worked more or less ok on intrepid. i'm off to test things out and i'll be back if i have anything useful to point out.

thanks again, wacky.
CryingSaul
New Python User
New Python User
 
Posts: 27
Joined: Wed Dec 10, 2008 12:49 am

Re: how to reference the right python

Postby Bill on Tue Jan 20, 2009 3:29 pm

CryingSaul wrote:all i wanted was to install a text editor. the efforts by the linux community to portray the os as user-friendly seem less and less convincing :)

First, the Ubuntu community is not the Linux community. I've seen enough commentary here and there to convince me that quite a few people in the Linux community are unhappy with the Ubuntu phenomenon. Apparently being well-funded and high-minded isn't aways enough. I'm coming to think that Ubuntu is intended to be end-user -friendly even at the risk of becoming developer-user-inimical. The whole idea of "putting a free OS in the hands of everyone" hints at that: what fraction of "everybody" wants to modify their OS' system software, as compared with those who want to play videos and audios, do office work, access the Internet to see UTube, and play games. In short I think an implication of Shuttleworth's stated goals is to make a high-grade replacement for Windows freely available. That includes being attractive to Microsoft's target demographic, and whoever they are they ain't developers.

I just got a new laptop with Ubuntu 8.10 installed, and I've had similar problems. Hell, imagine my surprise to find that emacs was not installed! After some poking around I have found most of the tools I was missing; synaptic made their installation very easy for the most part.
I tried installing Python 2.6 from source, and since I routinely spool out log files of configuration and make steps when I build I saw the message from make:
Failed to find the necessary bits to build these modules:
_bsddb _curses _curses_panel
_sqlite3 _tkinter bsddb185
dbm dl gdbm
imageop readline sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Using make altinstall I was able to get Python 2.6.1 installed under /usr/local as desired, but I am missing Tkinter, sqlite3, curses and readline. I'm not pursuing the matter very energetically at the moment since I'm comfortable using Python 2.5 (my only reason for installing 2.6 was to ease into 3.0 stuff) and I have other work on my plate.

After a month my feeling about Ubuntu is that it is quite slick and easy to use. I'm still unsure whether I made a mistake for my intended use.
-- Bill
Bill
Ultimate Python Hacker
Ultimate Python Hacker
 
Posts: 3612
Joined: Fri Nov 11, 2005 9:10 am
Location: Minnesota, USA

Re: how to reference the right python

Postby CryingSaul on Tue Jan 20, 2009 5:31 pm

i agree. it's just that on my eee pc i had the choice between windows xp and unix (disregarding leopard hacks) and i didn't want to go back to windows. figuring i had some experience with the unix command-line on my mac, i went for the linux distribution that seemed most popular. obviously, popularity has its share of problems...

anyway, i seem to have sorted out my 2.6.1 problems and i've just posted a long tutorial on how to do that in this forum. maybe it could help you.
CryingSaul
New Python User
New Python User
 
Posts: 27
Joined: Wed Dec 10, 2008 12:49 am

Re: how to reference the right python

Postby Wacky on Wed Jan 21, 2009 2:50 am

CryingSaul wrote:thank you for your answers. i'm afraid everything has gone downhill in a sort of snowball effect, with aptitude reporting around 30 unfixable broken packages and ipython suddenly unable to find readline. that os has gone to meet its maker and joined the bleeding choir invisible. i am currently reinstalling the whole system and trying to do something different, from scratch. i'll post if i find something useful. the tutorial will have to wait: )

Oh dear! :( I'm very sorry you've had such trouble with it.

for information, i found a post on the ubuntu forums saying:

My advise [sic] would be: don't upgrade Python if you are not ready to solve any problems with dependencies. many of your programs depend on Python and if you change it, something might go wrong.

Much safer choice is to wait until stock Python in ubuntu will be 2.6.

Yeah, it's best to leave things alone when possible, but 2.6 is so much shinier than 2.5... And really, it shouldn't be as hard as it seems it is -- which sucks. :(

as to the zlib/readline problem, there's a very detailed explanation of which dependencies needs to be installed without going through the whole --with syntax. the instructions are for hardy but it worked more or less ok on intrepid. i'm off to test things out and i'll be back if i have anything useful to point out.

Ah, that's encouraging, at least. Thanks for the link!

@Bill: You're absolutely right that Ubuntu community != Linux community. There's a fair bit of crossover between the two, though, it seems. Ubuntu is definitely much more user-oriented and focused (as you've observed), which I think is a good thing, and vital to Linux's long-term success as a user-friendly OS. It does mean that priorities sometimes clash, though, unfortunately.

Bill wrote:I just got a new laptop with Ubuntu 8.10 installed, and I've had similar problems. Hell, imagine my surprise to find that emacs was not installed! After some poking around I have found most of the tools I was missing; synaptic made their installation very easy for the most part.

If you bought it with Ubuntu pre-installed, then I hope your only "similar problems" (of significance, i.e. not just having to add emacs via Synaptic ;)) were Python-related, and that the rest of the system seemed fairly polished.

Bill wrote:I tried installing Python 2.6 from source, and since I routinely spool out log files of configuration and make steps when I build I saw the message from make:
Failed to find the necessary bits to build these modules:
_bsddb _curses _curses_panel
_sqlite3 _tkinter bsddb185
dbm dl gdbm
imageop readline sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Do bear in mind that some of those are normally not built on Linux, I think... sunaudiodev is definitely one, and gdbm is probably only if you compile a debug build (but I might be wrong). The imageop and dl ones I believe I recognise as being deprecated/unused, too. That still doesn't excuse it not automagically installing Tkinter, readline, and SQLite3, though. (:

Bill wrote:Using make altinstall I was able to get Python 2.6.1 installed under /usr/local as desired, but I am missing Tkinter, sqlite3, curses and readline. I'm not pursuing the matter very energetically at the moment since I'm comfortable using Python 2.5 (my only reason for installing 2.6 was to ease into 3.0 stuff) and I have other work on my plate.

Completely understandable. And I'm glad you put it in /usr/local, because it seems that -- even with make altinstall -- it will overwrite some existing Python bits if you install it to the same prefix.

Bill wrote:After a month my feeling about Ubuntu is that it is quite slick and easy to use. I'm still unsure whether I made a mistake for my intended use.

Debian might be worth a try if you end up not sticking with Ubuntu, but my main experience is with older Red Hat versions, and now Ubuntu. I know which of those I prefer from an "It broke! How do I fix it?" point of view. ;) I might try RHEL/CentOS again for a server, but I think I'd probably go with Ubuntu/Debian if only because it's easier to remember where system files are, and how everything works.

CryingSaul wrote:i agree. it's just that on my eee pc i had the choice between windows xp and unix (disregarding leopard hacks) and i didn't want to go back to windows. figuring i had some experience with the unix command-line on my mac, i went for the linux distribution that seemed most popular. obviously, popularity has its share of problems...

It does, unfortunately. I'd still take it Ubuntu (or any modern Linux) over Windows, though -- but I'm not your average user, I guess.

CryingSaul wrote:anyway, i seem to have sorted out my 2.6.1 problems and i've just posted a long tutorial on how to do that in this forum. maybe it could help you.

Excellent, glad to hear it!
The plus sign (+) is valid within an email address; please do not
write or suggest code that precludes its use, as many use it as a
"label" to filter incoming mail. </crusade> (Eek! Heresy, Imagist! ;))
Wacky
Python Guru
Python Guru
 
Posts: 673
Joined: Fri Aug 29, 2008 10:40 am
Location: EU

Re: how to reference the right python -- Update

Postby Bill on Sat Feb 14, 2009 2:24 am

Just a quick note for those interested. I finally found little time to work on this, and i appears like I have solved most of the problems. Looking over the list of must-installs I used Synaptic to install tk-dev, libsqlite3-dev and libreadline5-dev (this brought in libncurses5-dev as a dependency). I then did a make clean then reran configure, make, make test and finally make altinstall. Things went smoothly, there were no failed tests, and the only modules I appear to be missing are the specific DB support modules (which I didn't want anyway). The libraries and executables are in /usr/local/{bin,include,lib} as I wanted.

I think I am good to go.
-- Bill
Bill
Ultimate Python Hacker
Ultimate Python Hacker
 
Posts: 3612
Joined: Fri Nov 11, 2005 9:10 am
Location: Minnesota, USA


Return to Python General

Who is online

Users browsing this forum: No registered users and 1 guest


Sponsored by Dreamlink Web hosting and Traduzioni Rumeno Italiano and ASSP Deluxe for cPanel.