开发者

Help with Python structure in *nixes

开发者 https://www.devze.com 2022-12-29 20:23 出处:网络
I came from a Windows background whern it comes to development environments. I\'m used to run .exe\'s from everything I need to run and just forget.

I came from a Windows background whern it comes to development environments. I'm used to run .exe's from everything I need to run and just forget.

I usually code in php, javascript, css, html and python.

Now, I have to use Linux at my work, in a non changeable Ubuntu 8.04, with permissions to upgrade my system using company's repositories only.

I need to install Python 2.4.3 to start coding in an old legacy system. I had Python 2.5. I downloaded Python 2.4.3 tarballs, ran ./configure make and such. Everything worked out, but now the "default" installation is my system is Python2.4 instead of of Python2.5.

I want help from you to change it back, and if possible, some material to read about symlinks, multiple Python installations, virtualenvs and such: everything I need to know before installing/upgrading Python modules. I installed for example the ElementTree package and don't even know in which Python installation it was installed.

T开发者_如何学Gohanks in advance!


You may have installed Python 2.4 in /usr/local/bin, which, in turn, may come in your $PATH before /usr/bin where 2.5 lives. There are various possible remediations, if that is the case: simplest is probably to rm the link named /usr/local/bin/python (leaving only the "system" one named /usr/bin/python). You will then have to use explicitly python2.4 to invoke the 2.4 installation, while just python will go to the system-installed Python 2.5 installation.


If you have root access you could just create a new simlink.

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

I don't have too much experience with ubuntu, but i guess it shouldn't brake anything.

To learn more about ln read man ln.


For which version of Python will run when you invoke the python command you will have to manually change the symlink that /usr/bin/python points to, but that won't change what the packaging system considers the "default version of Python" and means you will still have to install version-specific libraries if they are different for a specific version. Luckily, those packages have an easy naming convention, instead of just python-<foo> they are python2.4-<foo> and installing those will put them in the right path (specifically the right site-packages directory).

EDIT: apparently python isn't managed by the alternatives system, silly Debian/Ubuntu


Running

 sudo apt-get install --reinstall python-minimal python python2.5

should restore the default Python installation.

Unlike Windows Ubuntu comes with quite a lot of software packaged by the distributor, and it is a good idea to stay with this packages if possible instead of downloading software from the net. Ubuntu 8.04 has Python 2.4.5 (package python2.4), maybe that works for you.

If you need to install Python from source use

 ./configure --prefix=/usr/local/

instead of a plain ./configure. This makes python to be install at /usr/local/ so it doesn't overwrite the distribution's files


Piggybacking off of @rebus:

sudo ln -s /usr/bin/python2.5 /usr/bin/python

Seems to have worked.

0

精彩评论

暂无评论...
验证码 换一张
取 消