Are there any downsides to upgrading Python on Snow Leopard? - python

I want to use the newest version of Python on Snow Leopard using the installer package, but I've read some confusing articles about conflicts when upgrading. I plan on using PyDev in Eclipse, will there be any conflicts with Snow Leopard if I upgrade?

To answer your question explicitly: Are there any downsides to upgrading Python on SL? Only if you upgrade the system installation. It can have strange repercussions on any system/CLI tools that use Python, and on any bundled applications (.app) that are utilizing PyObjC runtime libraries.
I would not upgrade, tangle with, or otherwise modify the default installation of Python, if that's what you are asking. You are much better off installing an upgraded version of Python in an alternate location using MacPorts.
MacPorts installs everything into /opt/local (i.e. /opt/local/bin/python) by default. You can then also install python_select which does some jiggering to make sure that whichever version you choose will be preferred based on your PATH.
You might want to consider using virtualenv coupled with pip for managing this environment as well, unless you become accustomed to MacPorts. Things to consider!

Related

Remove all Python versions and clean install Python 3

I have installed on my MacBook Air (v10.10.5) a number of different Python Versions (2.7, 2.6 + 3). I have tried changing python PATH settings, however, it has become too awkward to maintain. Because of this, I wish to uninstall all versions (without damaging my OS) and then clean install Python 3. How can I do this?
First of, you cannot (and should not!) uninstall a version of python that is shipped with macOS. They are shipped for a reason and might break your system as soon as you remove them (as a lot of essential processes might rely on them).
Python2.7 for instance has been shipped with macOS for a long time. However, you are also able to download and install the same version of python (e.g. 2.7) yourself, which usually means you end up with conflicting versions and controlling your PATH becomes a fulltime job.
You are always safe to remove those versions that you installed yourself (but only those!).
How to do so depends greatly on how you installed them. If you've done so via downloaded packages of python.org look here for uninstall instructions. If you used another application like brew or macports you need to follow the guidelines of those programs which could be easily fetched via a Google search.
Good luck!

Do I need to install Homebrew if I am planning to install Virtualenv?

Being fairly new to programming, I am having trouble understanding exactly what Homebrew does... or rather - why it is needed. I know it contains pip for package management, but so does Virtualenv and I'm planning on installing this in due course.
Does Homebrew install another version of python that is not the system version, upon which you would install Virtualenv and manage the different development environments from there?
I have a clean install of OSX Lion and I want to keep my projects separated, but am unsure why I need Homebrew.
I realise this is basic stuff, but if someone could explain it, I would be grateful.
Homebrew is just a package manager for Mac, like pip for Python. Of course you never need a package manager, you can just get all the programs, or libraries in case of pip and Pypi yourself. The point of package managers however is to ease this process and give you a simple interface to install the software, and also to remove it as that is usually not so simply when compiling things yourself etc.
That being said, Homebrew will only install things you tell it to install, so by just having Homebrew you don’t randomly get new versions of something. Homebrew is just a nice way to install general OSX stuff you need/want in general.
pip and virtualenv are python libraries and can be installed in any working python install including the one supplied by Apple as part of OSX and the python.org version.
Then it depends on what you need from python - if you just have to install python libraries or simple C linraries then you can just use easy_install and then pip, vittualenv other python tools.
If you are using more complex C libraries e.g. python interface for mysql then it helps to use a package manager like macports, homebrew or fink as the port writers will have sorted out the tricky dependencies. There are also other python installs from Enthought and Activestate that deal with some of the non simple cases e.g. scipy but are not general purpose package managers.
Macports and fink will install a separate version of python in /opt/local/bin or /sw/bin whilst I think homebrew will use Apple's python. *The difference is due to a difference of view of the package mangers design. Macports and fink were developed by people who experienced a lot of issues with different versions of software and so said that all our installs will be in a place only the package manager uses whilst Homebrew trys to use as much of the Apple supplied tools as possible so to add as little as needed.

how to install multiple python versions on snow leopard?

whats is the current best practice for installing multiple versions of python on snow leopard?
have setup python 2.7.1 via Homebrew, very easy process, all great.
but now I need to setup python 2.5 to develop an appengine project.. Initially created a new virtualenv against system python2.5 .. but finding I have all kinds of PATH issues. Seems at this point it would be better not to use Homebrew and go with a more standard setup?
any thoughts ?
Snow leopard already contains python 2.5 and python 2.6, no issues there.
If you require obscure modifications to the python installations, just compile your own, and put it in some place where it won't conflict with the system python. (I suggest /opt/your-pythonx.y).
As an aside, check: "man python" on mac to see how to use the 32-bit, or 64-bit options if that turns out to be neccessary. (Sometimes it is for c modules)
I use the python_select utility to switch between versions (it takes care of all the paths and links). It's easy to install with MacPorts or fink, so I would guess you can install the same utility with Homebrew.

Fedora Python Upgrade broke easy_install

Fedora Core 9 includes Python 2.5.1. I can use YUM to get latest and greatest releases.
To get ready for 2.6 official testing, I wanted to start with 2.5.4. It appears that there's no Fedora 9 YUM package, because 2.5.4 isn't an official part of FC9.
I downloaded 2.5.4, did ./configure; make; make install and wound up with two Pythons. The official 2.5.1 (in /usr/bin) and the new 2.5.4. (in /usr/local/bin).
None of my technology stack is installed in /usr/local/lib/python2.5.
It appears that I have several choices for going forward. Anyone have any preferences?
Copy /usr/lib/python2.5/* to /usr/local/lib/python2.5 to replicate my environment. This should work, unless some part of the Python libraries have /usr/bin/python wired in during installation. This is sure simple, but is there a down side?
Reinstall everything by running easy_install. Except, easy_install is (currently) hard-wired to /usr/bin/python. So, I'd have to fix easy_install first, then reinstall everything.
This takes some time, but it gives me a clean, new latest-and-greatest environment. But is there a down-side? [And why does easy_install hard-wire itself?]
Relink /usr/bin/python to be /usr/local/bin/python. I'd still have to copy or reinstall the library, so I don't think this does me any good. [It would make easy_install work; but so would editing /usr/bin/easy_install.]
Has anyone copied their library? Is it that simple?
Or should I fix easy_install and simply step through the installation guide and build a new, clean, latest-and-greatest?
Edit
Or, should I
Skip trying to resolve the 2.5.1 and 2.5.4 issues and just jump straight to 2.6?
Normally, you would only have one version of a python release installed. Since 2.5.1 and 2.5.4 are from the same release, copying your libraries should work fine. What you would need to watch out for, is that you now have /usr/bin/python, and /usr/local/bin/python in your path, and some utilities may get confused.
If you need to have both micro-releases installed at once, I would keep 2.5.4 out of your path altogether, or allow it to completely clobber the other (do so at your own risk though ;)
If you go with the former, you can also point 2.5.4 to your site-packages by using the PYTHONPATH environment variable.
Ubuntu takes a different route, and this is how you can handle different major releases. The python binary is given with the version appended:
/usr/bin/python -> python2.6
/usr/bin/python2.5
/usr/bin/python2.6
Each has their own /usr/lib/python2.X directory with versions of all the modules.
And lastly, you can further customize your setup by modifying your site.py
I suggest you create a virtualenv (or several) for installing packages into.
I've had similar experiences and issues when installing Python 2.5 on an older release of ubuntu that supplied 2.4 out of the box.
I first tried to patch easy_install, but this led to problems with anything that wanted to use the os-supplied version of python. I was often fiddling with the tool chain to fix different errors that might crop up with every install. Installing any python software via apt, or installing any software from apt that had a python easy_install script as part of the install, was often amusing. I'm sure I could probably have been more vigilant in patching easy_install, but I gave up.
Instead, I copied the library, and everything worked. As you say, there may be issues depending on what you have installed, but I didn't run into issues. Double-checking Python's site.py module, I did see that it operates entirely on relative paths, building absolute paths dynamically; this gave me some confidence to try the "copy everything" approach. I double-checked any .pth files, then went for it.

Install PyObjC on Python 2.6 on OS X 10.5?

OS X 10.5.8 came with Python 2.5, and had PyObjC already installed.
I installed Python 2.6 from the python.org site, and PyObjC isn't there.
I can't find a download to install PyObjC on my Python 2.6 install. Is checking out the PyObjC trunk and trying to build it my only choice? Will that work "out of the box"?
Apple includes PyObjC with their Pythons that come with OS X 10.5 and 10.6. It is not part of the python.org installers. But it should be easy enough to install. Just install setuptools to the python.org python 2.6 following the instructions here. Then use easy_install-2.6 (which will have been installed in /Library/Frameworks/Python.framework/Versions/2.6/bin and may already be on your $PATH) to do:
easy_install-2.6 pyobjc==2.2b2
as described here. If you want to live on the bleeding edge, you could try installing directly from the svn repository as there has been a lot of work recently, primarily in support of 10.6.
If that seems like too much work, you could install an older version and all dependencies including python via MacPorts:
sudo port install py26-pyobjc2
You should probably try to build PyObjC from trunk, which will work fine on the official Python 2.6 distribution, but not on Python 2.5. There are quite a lot of fixes in the trunk right now that weren't in 2.2b2, which afaik. is the most current version available through easy_install.
There are some little snags that you may run into when building with py2app on 10.5 + 2.6 + PyObjC 2.2 (which for a lot of reasons is what you should probably do, instead of using the Xcode templates from 10.5 that build differently), especially if you still have Python 2.5 installed somewhere, so you'll probably want to build and install py2app from trunk as well, this particular issue I ran into with PyObjC 2.2 on 2.6 on 10.5 has been fixed by now.
If your goal is to write software that will work on other people's computers, you shouldn't touch the default Python installation. If you simply cannot live without 2.6, then you're responsible for re-creating everything on your own, and that's not going to be a point-and-click process by any means.

Categories

Resources