So I installed python 2.7.11 a few months ago, now the class I'm about to take uses 3. So I installed 3 and it works fine. I also uninstalled 2.7.11 by going to applications and removing it, but going to terminal and typing which python, the directory is Library/Frameworks/Python.framework/Versions/2.7/bin/python, which means this it's still not removed.
What should I do...leave it alone? I only need Python 3, but this is bothering me a bit.
Thanks.
This doesn't answer the question in the post's title, but leave Python 2 as the default python. If you want to run Python 3, you run python3 or maybe python3.4 or python3.5, depending on your installation. The system and other third-party software depend on python being Python 2. If you change it, you may encounter puzzles down the road.
I'm not sure if having a third-party Python 2 is good (OS X ships with Python 2 already), but it should be fine.
Edit: Sorry, didn't see there was already an answer. It was posted as I was typing.
Related
I am working on a small education project which will use Python SimpleHTTPServer from a shell script to serve static files from a folder like this:
python -m SimpleHTTPServer
I am not sure on which platforms the project will be run.
I don't think users will run it in some exotic environments - generally OSX, Linux, Windows.
Will it be enough to write in docs that Python is required to run it?
No, this will not be sufficient in 2018, and even less so in the future. You should tell them to use python3 -m http.server, and that Python 3 is required, but with a note saying they can use SimpleHTTPServer from Python 2 if they have that instead—and probably mentioning than Mac users do already have Python 2 instead.
(I'd like to say that you can get away with ignoring Python 2 entirely, because anyone who chooses to use it ought to know what they're doing by this point, but thanks to OS X, you can't quite get away with that yet.)
Windows: Users who go to python.org to install Python will be presented with 3.6 as the first choice, and 2.7 as the second choice. And in a year and a half, 2.7 will likely be moved to the "old versions" page along with 3.5 and 2.6.
Mac: Python 2.7 comes preinstalled. If they go to python.org, or use Homebrew, they'll be presented with 3.6 as the default, but if they know that they already have Python, they won't try that. And Apple may well keep shipping 2.7 long beyond 2020.
Linux: Current versions of most distros have 3.x preinstalled, and some do not have 2.x. And in a year and a half, most of the big ones are planning on relegating 2.x to community-package status. However, there are plenty of people still using older "Long-Term Support" versions of their distros, and these will continue to support (and maybe pre-install) 2.7 until they go out of support, which ranges from 2-8 years from now.
SimpleHTTPServer is only available on Python 2.x.
For 3.x you need to run it as python -m http.server.
Also, it might be worth mentioning that you can add port as an extra argument. (python -m http.server 1234 or python -m SimpleHTTPServer 1234)
Referring to in in the documentation should be enough I guess.
Linux and OSX should come with python preinstalled. (As far as I know).
For windows this isn't always the case. Some installations do, some don't.
I would like to upgrade my Python version from 2.6.6 to the newest version of 3.6.5 on a server. However, there is a program that has been running for multiple days and will be running for a week or more.
Will my program continue to run until it finishes if I upgrade my Python version?
P.S.: I ran my Python program with the screen command so I wouldn't have to stop it to be able to upgrade my Python version.
Yes, your Python 2 script should continue to run while you install/upgrade Python 3, since Python 2 and 3 are different programs.
However, the installation will be be platform specific and there might be common dependencies, so I would test this on a different machine (e.g. local virtual machine) first.
Several aspects are to be considered here:
In general, a Python program that is running does not access the installed binaries of the interpreter anymore. Also all the modules already loaded will not be read again from disk during the execution time of this program. (In this aspect it differs from e. g. a Bash script which reads its script source while executing.) So you probably are safe in even removing the complete Python installation; of course that's not what you plan on and I wouldn't recommend it for other reasons, but even that should not influence your running Python program. If, however, your running Python program tries to import a module for the first time after the removal or upgrade of your Python installation, this might fail due to incompatibilities between the versions. Most programs do their imports only at the beginning of their runtime, though.
Python 2 and 3 are different languages. Scripts for the one need to be at least adjusted to run with the other. Adjustments aren't too hard to do, though. Most distributions have both installed side-by-side. Most of the time, Python2 is still standard (and accessed by typing python). python2 and python3 are then to make it explicit. This means that you probably should not remove Python 2 from your system, even if you plan on installing Python 3. There probably are scripts relying on the installation of Python 2.
There's a lot going on here that you've not explained/described, so it's hard to give you a definitive answer (such as the operating system you're using). This is also not exactly a programming question, so you might find that the question gets voted to close. That said...
It possible to run multiple versions of Python side by side. Because 2.x and 3.x are very different, it might be much better to have both versions installed. See this answer for some details on doing that:
Official multiple Python versions on the same machine?
It's likely that your code will need some modifications to run on Python 3, so you're going to have to redeploy a new version of your code at some point anyway.
Old-time user, first-time asker here,
I am very new to Python, and I started by downloading Anaconda with Pyhon 3.6. I tried to get gcalcli to work, but it's having big Python version conflicts. It looks like gcalcli was made for Python 2, but then my "default" Python is 3. Many of the modules gcacli needs have also been installed for Python 3. I think that even the print command has changed between the two versions.
I believe I have all the necessary modules installed: Google API Client, dateutil, gflag, but their versions might be part of the problem.
I can run gcalcli from Python 2 (by changing the first line in the gcalcli file) but it will crash when a Python 3 module is needed and the syntax is strange. I also tried running gcacli from Python 3, but the same happens when it runs into syntax that only works for Python 2.
I tried copying the content in the Python36/Lib folders to Python27/Lib, and run gcalcli from Python 2. That helped the program run a bit further, until it ran into another incompatible bit of syntax. In other words, I'm kinda trapped in version hell.
Has anyone found a solution for this kind of version and script/module compatibility problem?
Thank you, very much.
I mistakenly deleted the old python installion on my system, i then downloaded the new python 3 release however when i type python into the terminal it still looks for it in the 2.7 directory. I looked through a few questions that said something about updating the path variable however ive had no luck, as to me it seems that python is only 4 files installed in the applications folder. I really would appreciate some help. Thank you
It is better if you reinstall your system from recovery mode. A lot of OSX software can rely on system python, even if it is not python projects. Then recomended way is use homebrew. You can have different python (2.7, 3.3, pypy) versions the same time.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Can I install python 3.x and 2.x on the same computer?
I am learning Python which I started with 3.2. Now I know basics and want to use some frameworks to learn web development. Here, I came to notice Django doesn't supports Python 3x yet.
So, I need to use Python 2x on same machine. How can I install both?
PS. I am currently using Windows XP.
Just install them normally. By default each version of Python is installed to a different path, and won't conflict. Python 3 and Python 2 don't even use the same executable name (python vs python3), so there's not a lot to worry about.
they will install into C:\Python27, and C:\Python32 by default.
no conflicts.
i didn't want to answer this but i have to since you might have a problem that no one is talking about lol
first don't install python from the official website go to activestate and download activepython for python 2,7
here's a direct link
http://downloads.activestate.com/ActivePython/releases/2.7.2.5/ActivePython-2.7.2.5-win32-x86.msi
activepython will help a lot when downloading packages trust me, so to install django, open pypm and type pypm install django
learn python 2.x and not 3.x because:
1-All the modules work on 2.x and not 3.x, python is a modular language, it's useless if you can't find modules
2- python 2.x will be there for at least 5 years so there's a long time for you to get started on 3.x maybe by then it will be more supported
3-now we are using 2.7, starting from 2.5 python started doing small changes to help programmers have a smooth transition from 2.x and 3.x, so when 2.9 arrives it will look a lot like 3.x
4-if you installed 2.7 and 3.2 on xp and lets say you made 2.7 your default version, which is the right thing to do, then there's a big possibility that 3.2 won't work, it will give you this error: Error runtime
program C:\python32\pythonw.py
this application has requested the runtime to terminate it in an unusual way, please contact the application support team for more information
so it will just give you a headache lol