ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am a new python user trying to get 3.0 to work on my computer. While trying to change the default version of python from 2.4.3 to 3.0, I followed the advice of another forum and changed typed
rm /usr/bin/python
into the console to remove the link to the old python.
I then entered
ln -s /usr/bin/python3.0 /usr/bin/python
but after doing so my computer no longer recognizes the "python" command.
Is there any way to fix this so that I can use python again?
Distribution: sabayon 5, slack64, Lenny, LFS 6.4 user # 20665
Posts: 61
Rep:
Quote:
Originally Posted by blueheron66
I am a new python user trying to get 3.0 to work on my computer. While trying to change the default version of python from 2.4.3 to 3.0, I followed the advice of another forum and changed typed
rm /usr/bin/python
into the console to remove the link to the old python.
I then entered
ln -s /usr/bin/python3.0 /usr/bin/python
but after doing so my computer no longer recognizes the "python" command.
Is there any way to fix this so that I can use python again?
You removed /usr/bin/python (via the rm command), so you can't link python3 to a non-existent location. Here's 3 options:
1. Re-install python 2.x, download the python3 source and choose make fullinstall to overwrite the 2.x installation.
2. You can have multiple versions using make altinstall.
3. Try ipython.
From the python3.0 README:
Converting From Python 2.x to 3.0
---------------------------------
Python 2.6 contains features to help locating and updating code that needs to be changed when migrating to Python 3.
A source-to-source translation tool, "2to3", can take care of the
mundane task of converting large amounts of source code. It is not a
complete solution but is complemented by the deprecation warnings in
2.6. This tool is currently available via the Subversion sandbox:
On Unix and Mac systems if you intend to install multiple versions of Python using the same installation prefix (--prefix argument to the configure script) you must take care that your primary python executable is not overwritten by the installation of a different version. All files and directories installed using "make altinstall" contain the major and minor version and can thus live side-by-side. "make install" also creates ${prefix}/bin/python which refers to ${prefix}/bin/pythonX.Y. If you intend to install multiple versions using the same prefix you must decide which version (if any) is your "primary" version. Install that version using "make install". Install all other versions using "make altinstall".
For example, if you want to install Python 2.5, 2.6 and 3.0 with 2.6 being the primary version, you would execute "make install" in your 2.6 build directory and "make altinstall" in the others.
blueheron66: can you verify with ls that /usr/bin/python -> /usr/bin/python3.0 ? Can you execute /usr/bin/python3.0 as a command by itself? Where there any errors when you made the link? It's hard to tell what could be wrong without some more information.
Quote:
Originally Posted by agrestic
You removed /usr/bin/python (via the rm command), so you can't link python3 to a non-existent location.
The arguments for ln are DEST SRC so `ln -s /usr/bin/python3.0 /usr/bin/python` will work just fine.
The arguments for ln are DEST SRC so `ln -s /usr/bin/python3.0 /usr/bin/python` will work just fine.
I think you meant SRC DEST, but yes, the command should work. It won't give an error even when SRC is non-existent, and goes ahead and creates /usr/bin/python. ls -l /usr/bin/python* and which python3.0 would help see what went wrong here.
I think you meant SRC DEST, but yes, the command should work. It won't give an error even when SRC is non-existent, and goes ahead and creates /usr/bin/python. ls -l /usr/bin/python* and which python3.0 would help see what went wrong here.
Yes, I suspect python3.0 may not be installed in /usr/bin. I installed mine in /usr/local/bin, so that command would not have worked for me either.
I think you meant SRC DEST, but yes, the command should work.
No, I meant the link starts at SRC and points to DEST. [Not that it really matters.]
blueherron66: Looks like a Mac? From this listing, there is no /usr/bin/python3.0 for the link to go to. I'm not a Mac user, but perhaps /System/Library/Frameworks/Python.framework/Versions/3.0/bin/python exists and if it does you should also make a link from /usr/bin/python3.0 to point there. Basically the link means "when I use the SRC file, actually access the DEST file." So when you have /usr/bin/python -> /usr/bin/python3.0 that means access to /usr/bin/python actually go to /usr/bin/python3.0 (that's the explanation in a nutshell). Since /usr/bin/python3.0 does not exist for you, bash complains. You must create /usr/bin/python3.0, probably by following the link pattern which /usr/bin/python2.3 uses (notice how it points to /System/.../2.3/bin/python).
It this works, and your shell still does not recognize the command `python', then it may have to do with shell hashing.
Basically, when you use a command, shells like BASH throw the name and location into a table so that it does not have to go find the binary next time that you use the program.
To verify that this is the case, turn off hashing:
Thanks so much for all the help so far. I looked in System/Library/Frameworks/Python.framework/Versions and it looks like 3.0 never installed corectly. All I have is 2.3 in that folder when I should have 3.0. It looks like I have some problems with installing python 3.0 to figure out before I try to change the default version.
When I tried to restore the link between /usr/bin/python and its counterpart, bash claims that /usr/bin/python does not exist, even though I can see plainly that it DOES indeed exist, as I have checked manually.
ln /usr/bin/python /System/Library/Frameworks/Python.framework/Versions/2.3/bin/python
ln: /usr/bin/python: No such file or directory
ln /usr/bin/python /System/Library/Frameworks/Python.framework/Versions/2.3/bin/python
ln: /usr/bin/python: No such file or directory
Oh noes! Don't do this as root. This command would make /System/Library/Frameworks/Python.framework/Versions/2.3/bin/python point to /usr/bin/python -- more than likely not what you want. The arguments for ln are the thing pointed to and then the thing which does the pointing. DEST then SRC. This is because the SRC is optional and when it is missing ln creates the last path component name of DEST in the current directory as the thing doing the pointing.
Last edited by taylor_venable; 01-08-2009 at 09:58 PM.
Reason: cleaned up wording a bit
Oops... I fixed the ordering of that command and now i am prevented from creating that link because /usr/bin/python DOES exist. Sorry if these questions seem dumb; I'm not experienced with using the terminal or python.
By default, ln won't overwrite something which already exists with a link (precisely to prevent such accidents) so you can either just rm /usr/bin/python first or use the -f option to force an overwrite. You probably want to use the -s option to specify a symbolic link as well.
The questions aren't dumb. I've been caught forgetting myself on the file order as well. You should read man ln to get a good impression of what a command does before running it though.
SUCCESS!!!1!1 At least now I'm back to square one. Thank you for your help and for informing me of the "man" command. Using "man" will help me help myself rather than burdening the internet with my console questions. It would seem that the link to installing a newer version of macpython on the python website leads only to framework based add-ons. I have installed a few of these and hope to take advantage of their features soon. The inpression that I'm getting from the python website is that the newest version of python that readily works for OSX 10.4 is 2.4. The makefile for versions newer than 2.4 has trouble making a couple modules that I'm currently trying to find and fix...but that's another story.
Thank you for your help.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.