Install Python 3.1 on Mac OS X version 10.5.8 - python

I use Windows. I wrote a Python 3.1 script that my Mac-using friend would like to run, but we can't get Python 3.1 to work right on his Mac. I think the problem is that the Python 3.1 framework is not being installed. Here's exactly what what I did and why I think this is the problem.
I downloaded Python 3.1.2 from the Python download page (this file). I opened the file, then opened "Python.mpkg". I proceeded with the install wizard, and I made sure to check the box to install "Shell profile updater" during the wizard. I went to "/Applications/Python 3.1" and double-clicked "Update Shell Profile.command".
Next I selected the python script I wrote and selected "File", "Get Info" in the menu bar.
Under "Open With" I selected "PythonLauncher" from "/Applications/Python 3.1". I then clicked the "Change All" button. Now I double-clicked my program to run it, but it was run by Python 2.5.1 instead of Python 3.1. (I'm sure of this, I wrote a program to "print(sys.version)".)
So now I tried to figure out why the "PythonLauncher" from "/Applications/Python 3.1" is using Python 2.5.1. I opened "PythonLauncher" and found that the interpreter for "Python Script" is "/usr/bin/pythonw". So I went to "/usr/bin/" and discovered that "pythonw" was an alias pointing to "/System/Library/Frameworks/Python.framework/Versions/2.5/bin/pythonw2.5". Obviously this should be version 3.1 instead. So I went to "/System/Library/Frameworks/Python.framework/Versions/" and discovered that the only sub-folders are "2.3" and "2.5". Where's 3.1?

Take a look at PythonBrew. It made installing Python on my Mac a lot easier.
Also this might help:
Is there a Python Equivalent of Ruby's RVM?

Python Launcher.app is a somewhat neglected app; there have been some discussion about removing it all together because it could be somewhat of a security risk if someone downloads arbitrary Python scripts from the web. It can also be kind of hit or miss if you have multiple Python versions installed. And many people just run Python from a terminal window command line so they don't need Python Launcher.app and that's probably the safest thing to do. To do so, you should first run the Update Shell Profile command in /Applications/Python 3.1 which will ensure that the proper Python framework bin directory is added to your shell path. Then you can just type:
$ python3 /path/to/script.py
That said, you can make Python Launcher work by changing the interpreter path to:
/Library/Frameworks/Python.framework/Versions/3.1/bin/python3
but I discourage you from doing so.
Another better GUI option is to launch IDLE.app and drag-and-drop files onto it in the dock or open them in its File menu.

The versions in /System/Library/Frameworks/Python.framework/... were put there as part of OS X. They should be left alone. (See this question.)
.dmg files downloaded from python.org install to /Library/Frameworks/Python.framework/.... These are user-installed, so you can install/uninstall/move however you like. These installers also created symlinks in /usr/local/bin.
You can add either /Library/.../3.1/bin or /usr/local/bin to your path in your shell if you want python3 to be on your path.

Related

Why is python setup popping up when I start Pycharm and where is my python interpreter?

When I start Pycharm, this python setup menu pops up.
Python 3.7.4 is not even the version I'm using. Everything else works fine and I can just close it, but it is annoying.
There was a same question, and the answer was
You appear to be using the installer .exe as if it were the Python interpreter. Install Python to somewhere first, then use the python.exe in the bin directory inside that.
But I can't find where my bin directory is. My Python37-32 folder looks this.
How do I find my python interpreter?
Open some project -> File -> Settings -> Project: ... -> Project Interpreter -> Show All ... to view the list of available interpreters added to PyCharm.
Find and remove the interpreter which is pointing to Python distributive from the newly opened list.
At some point in past you added Python installer as a project interpreter in PyCharm so now when IDE tries to use this exe to run some background tasks (e.g. to get sys.path) installation wizard is triggered instead.
Correct python.exe to point PyCharm to is right on your screenshot
According to official python documentation.
The Python interpreter is usually installed as
/usr/local/bin/python3.8 on those machines where it is available;
putting /usr/local/bin in your Unix shell’s search path makes it
possible to start it by typing the command:
Since you are using Windows here, you are already in the location where the python interpreter resides. So look no further.
By the looks of the screenshots, I have a concern whether you have installed python correctly.
If you did not select the checkbox for Add Python 3.7 to PATH, the wizard expects you to do it manually which is why the error.
I would uninstall and reinstall Python and this time make sure to check that box. I am sure your error messages should go away.
Alternatively, if you're not in the disposition to uninstall. According to python docs here you can set the python variable to PATH variable and try.

Unable to run python in CMD

I have recently started learning python using code academy and today I downloaded everything that I thought I would use. I downloaded Python and Atom. I have two separate drives on my computer. An SSD with not much storage and a hard drive with a lot of storage. My Windows is installed on the SSD, but I wanted to download python and atom on the hard drive, so I did so. When I installed Python I made sure to check add to PATH and the environmental variable thing. Now when I go to the command prompt, it shows "C:\Users\Gustavo>" but my python is installed on a different drive. Is there a way I could make this work? Thanks a lot.
There are two ways to install python:
Download directly from the website
Use a package manager
Case 1: Download directly from the website
Go to the python's website to download the version you would like to use.
Install the downloaded file (During the installation you can customize the installation directory)
Make sure to enable "Add python.exe to Path"
After installation has been completed, open your command prompt and type where python. Your python directory should be printed.
If all is good, then typing python should launch python in your command prompt. You can also run python by cd in the directory where your python is located and launch the .exe
You have mentioned about changing path and environmental variables, and that's probably for the purpose of keeping multiple versions of python. If that's the case, there's actually a quick fix for this:
Go to the folder where you installed Python.
Copy the python.exe file, and rename that copy in the same directory as python3.exe (If you installed version 2, then rename as python2.exe).
Now in command prompt type python2 or python3 and you should be able to launch either versions respectively.
Note: If you face issues regarding paths, then you should detail the error messages.
Case 2: Use a package manager
Choose a package manger: chocolatey, scoop, and others.
Check out these links for changing package manager's installation directory, installation method varies by the managers, so you should consult the developers should you experience problems:
chocolatey
scoop
Package managers will manage the versions for you, if you choose to install multiple versions. You should refer to the package manager's website for detailed information. However, you can quickly check the installed version by typing python --version. The python version number should be printed back to you, same applies to python3.
Double check your installation directory by which python
Type python or python3 to run your python of choice.
Lastly, you have mentioned atom. Atom is just a text editor: you can write python codes with it.
When you are done editing, you can open the command prompt and navigate to where your code resides, and type
python filename.py
This will run your code directly from the command prompt. There are many atom plugins available to make this process seamlessly integrated within atom. iPython and Jupyter plugins are first things that comes to my mind, you should specifically check out Hydrogen.

Python3 not found [duplicate]

I installed python3, I can open idle and it says it is running python3.0.1, but when I enter python3 in the terminal (on OSX) I get an error saying 'command not found'. Entering python gets me the 2.x version that came on the computer. Any advice on how I can access python3 from the terminal?
Thanks
First, don't use Python 3.0.1. It has many problems and was officially retired upon the release of Python 3.1 (currently 3.1.2). You can find the python.org Mac OS X installer for 3.1.2 here. Once it is installed, then you need to ensure that the bin directory from the 3.1.2 framework (/Library/Frameworks/Python.framework/Versions/3.1/bin) is on your shell search path. You can manually modify an appropriate shell startup file, like .bash_profile. Or just double-click the Update Shell Profile.command found in /Applications/Python 3.1. In either case, you will need to open a new terminal window or re-login. Another approach is to install Python 3.1 from MacPorts or another distributor. Also, alpha releases of Python 3.2 are now available from python.org and elsewhere.

How can I install Eclipse Indigo on Windows 7

I've downloaded Eclipse Indigo in preparation of using it to write apps in Python. There doesn’t seem to be an install file. When I double-clicked eclipse.exe the program just ran. Can I move the Eclipse directory anywhere I want it, create a shortcut and place it on my taskbar, and start writing programs?
I put the Eclipse directory in my Path statement, and tried to run it from the command line. It won’t run anywhere but in the Eclipse directory. I already have Python 3.2 installed and it does run anywhere from the command line. Will Eclipse automatically find my Python executable or do I have to do something else?
The instructions are pretty clear ... and pretty simple:
Install your JDK on Win7 (I'd choose the 64-bit JVM for 64-bit Windows, but 32-bit will work on 64-bit Windows equally well)
Unpack the "eclipse" folder from the .zip file anywhere you want. Mine happens to be in c:\eclipse.
Manually create a desktop and/or start menu link to eclipse/eclipse.exe
Here's a great reference on "PyDev":
http://www.vogella.com/articles/Python/article.html
I'd also encourage you to install the latest/greatest Eclipse ("Juno") instead of Indigo.

Installed python3, getting command not found error in terminal

I installed python3, I can open idle and it says it is running python3.0.1, but when I enter python3 in the terminal (on OSX) I get an error saying 'command not found'. Entering python gets me the 2.x version that came on the computer. Any advice on how I can access python3 from the terminal?
Thanks
First, don't use Python 3.0.1. It has many problems and was officially retired upon the release of Python 3.1 (currently 3.1.2). You can find the python.org Mac OS X installer for 3.1.2 here. Once it is installed, then you need to ensure that the bin directory from the 3.1.2 framework (/Library/Frameworks/Python.framework/Versions/3.1/bin) is on your shell search path. You can manually modify an appropriate shell startup file, like .bash_profile. Or just double-click the Update Shell Profile.command found in /Applications/Python 3.1. In either case, you will need to open a new terminal window or re-login. Another approach is to install Python 3.1 from MacPorts or another distributor. Also, alpha releases of Python 3.2 are now available from python.org and elsewhere.

Categories