Python3 not found [duplicate] - python

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.

Related

Using Homebrew python instead of system provided python

I used Homebrew to install python, the version is 2.7.10, and the system provided version is 2.7.6. My PATH environment variable is set to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin", so my terminal DOES know to look at the Homebrew bin folder first!
However, when I run python, it still defaults to 2.7.6, the system provided version (the interpreter that shows up says 2.7.6 at the top). If I run /usr/local/bin/python, it runs 2.7.10, which is what I want.
If my PATH variable is properly set, then how is it possible that terminal still finds /usr/bin/python first?
This happened to me when I installed Python 2.7.10 using brew. My PATH was set to /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin and which python returned /usr/local/bin/python (which is symlinked to Python 2.7.10.)
Problem went away when I closed and restarted Terminal application.

How Can I Downgrade from Python 3.2 to 2.7?

I am trying to uninstall Python 3.2 and go back to 2.7, I do not have much experience with Python, and as I am learning now, it is becoming increasingly difficult to manage all of the work arounds needed to work with the newest version, and I require 2.7 for a college course.
I tried using the Windows 7 add/remove programs to uninstall Python 3.2 and 3.1, and then I downloaded and installed the 64 bit Python 2.7, but I was unable to open any of my already existing .py files with the executable in the Python27 folder.
When I click to open any .py file, I don't see any error messages but Windows asks what program to open the file with, and if I choose python.exe or pythonw.exe in C:\Python 27 I get a console Window appearing briefly and then closing. The "edit with IDLE" option in the context menu is gone, and if I try to edit with IdleX, I get another "what application to open with" window.
Instead of removing python 3.2, you can use both of python 2 and 3 in the same time. You just need to specify which version you want to use.
When in CMD, you can see the available versions installed on your windows. If it doesn't appear there, you need to install it.
py -0 # Prints out the versions you can use.
You can specify which python version you want to use.
For example in Windows 10, I use the code below for python 3.
py -3 fileName.py # runs using python 3
For python 2, you can use the code below after installing it.
py -2 fileName.py # Runs using python 2
Here is more information about installing more versions of Python in the same time.
How to install both Python 2.x and Python 3.x in Windows 7
Python 3.x is not backward compatible with Python 2.x, which was the purpose of the release. To clean up Python2.x without worrying about backward compatibility.
You can have as many python installations as you want on your computer, as they do not interact with each other. The python installations have it's own folder, with it's own idle, modules, launcher, ect.
You could install PyCharm or another Python IDE. It allows you to change which version of python you use to interpret your code. This will also identify syntax errors as you are writing and will notify you of them - in case you have code that works in 3.x but not 2.x.
Ecker00 is right, installing 2.7 in a separate directory gives you access to 2.7 while still having 3.x on your computer. You will have to re-install libraries with the Python27 folder's pip in order to use them in 2.7 though.
You can also change your python version using anaconda:
conda install python=3.5.0
or maybe
conda install python=2.7.8
or whatever you want.
Use the following steps to get it fixed.
//Check current Python pointer
ls -l python
//Check available Python versions
ls -l python*
//Unlink current python version
sudo unlink python
//Select required python version and lin to python command
sudo ln -s /usr/bin/python2.7 python
//Confirm change in pointer
ls -l python

Force PyCharm (1.5.4) configured interpreter to use 32-bit OSX Lion Python distribution (2.7.1)

I know how to start PyCharm in 32-bit mode on OSX Lion, but how do I get the interpreter configured in PyCharm to use the 32-bit version of the Apple shipped Python version (currently 2.7.1)?
I successfully have it working when launched from the terminal, but it appears that PyCharm doesn't read those system variables or defaults.
I'm trying to get cx_Oracle working with some scripts in PyCharm. Please see the following question for more details:
Can't get cx_Oracle to work with Python version 2.7 / mac os 10.7.2 (Lion) - missing_OCIAttrGet
Thanks in advance for your response!
I don't use PyCharm so I can't test this but it appears you can configure a non-standard path to the Python interpreter (see PYCharm help here). If so, try using /usr/bin/python as the path. If you've used the defaults command to permanently set 32-mode (as documented in Apple's man python):
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
that should do the trick. Setting the environment variable probably won't work.
UPDATE: Since you report that that does not work, here's another, more drastic possibility. You can extract the 32-bit architecture binary from the multi-architecture (universal) binary by using the lipo command. Try something like this:
sudo lipo /usr/bin/python2.7 -extract_family i386 -output /usr/local/bin/python2.7-32
sudo chmod 755 /usr/local/bin/python2.7-32
Then set the interpreter path in PyCharm to that file. It's ugly because you will need to keep an eye on any Python updates from Apple and repeat the process. If PyCharm is exec-ing the Python executable directly from the framework, then this may not work. Short of getting some support in PyCharm or resolving the Oracle issue, the fool-proof solution would be to install a 32-bit-only version of Python. The pre-built 32-bit-only installers from python.org are problematic for Lion 10.7 because of their dependence on gcc-4.0 and the 10.4u SDK, both no longer provided in Xcode 4. However, you could build it yourself or, with a little bit of configuring, you should be able to get MacPorts to build one.
For some reason none of that worked for me. Kind of lame that pycharm doesn't support this..
I ended up adding the BASH support plugin to PyCharm: Preferences > Plugins > Browse Repository > BashSupport
Then I add a new bash file to my project with the content:
#!/bin/bash
arch -i386 /usr/bin/python ./<your script name that's in the same directory here>
Run it by right clicking and running. Now it'll appear in your 'configurations' drop down.
Now you can run the script as 32-bit python, see the standard out, and edit the .py file.

python 3.2 installed, but MAC didn't recognize it

I installed python 3.2 edition, but when I opened wingIDE, my MAC still only show the old edition phthon 2.6.1. I tried to use "configure python"-enter python3.2 in "python executable", then found nothing changed, python 2.6.1 still appeared in wingIDE. Any suggestion?
I just tried to launch WINGIDE again and this time it indicates the python 3.2, the newest edition i installed. hmmmm, funny, i didn't change anything and it recognized it now! But when i use terminal, it still only recognize python 2.6.
Is python3.2 in your PATH? Try typing "python3.2" at the command line and see if that works. Where is python3.2 located? It's probably /usr/bin/python3.2 Try using that in WingIDE and see if that works.
This may depend on the version of OSX you are running. I did a custom install of python 2.7 on my machine running 10.6.7 and had to modify ~/.bash_profile with the following line:
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
You may want to check the directory /Library/Frameworks/Python.framework/Versions and see what the full path is to your 3.2 install. You could then modify the PATH variable in your ~/.bash_profile like this:
PATH="/Library/Frameworks/Python.framework/Versions/YOUR_VERSION_NUM/bin:${PATH}"
trying to fix wing myself, but if you want to just execute it via commandline...
in terminal:
python3.2 ./filename.py
enjoy
The reason is because the "python" shortcut doesn't exist in "/Library/Frameworks/Python.framework/Versions/3.4/bin", which is the newly created binary location.
Create a soft link to "python" as a work around.
"ln -s python python3.4".
Also, make sure that your .bash_profile has an entry for /Library/Frameworks/Python.framework/Versions/3.4/bin directory.
Verify with "Python -V"

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