Trying to install Django via Macports on Leopard - python

I have Python 2.6 & 3.1 installed on Leopard via mac ports with no problems. I want to install Django 1.2 via mac ports for Python 2.6, but a google search of how to do it seems to point me in the wrong direction. Can anyone point me in the right direction? Thanks again.....

Just don't do that. Install it directly from source.
Or better, use easy_install:
easy_install django
Or even better, use pip (and add virtualenv as a bonus (and virtualenvwrapper for more fun!)):
pip install django

What is wrong with this package?
$ port info py26-django
py26-django #1.2.1 (python, www)
Variants: bash_completion, universal
Description: Django is a high-level Python Web framework that
encourages rapid development and clean, pragmatic design.
Homepage: http://www.djangoproject.com
Library Dependencies: python26, py26-distribute
Platforms: darwin
License: unknown
Maintainers: arthurk#macports.org

Just "throw" the django tarball within the site-packages (dist-packages in py2.6+) and you are done. What for do you need macports etc, with a pure python library?

Related

Bottle Version Python Web Framework

Need help with bottle, I have a clean installation of Ubuntu 11.10, i'm
trying to get bottle with the next command : sudo apt-get install python-bottle, and i get the bottle version 0.9.5-1 , that's not the last one(0.10.6-1) and does not include some features that i need.
Anybody knows why? I do not want to use easy-install or pip, help!
You'd need to upgrade your Ubuntu installation to precise (version 0.10.6) or to quantal (version 0.10.11).
Older Ubuntu releases do not get new versions of packages; python-bottle is also not part of the Ubuntu backports packages.
I strongly advise you to use a virtualenv and install the latest bottle version in there with pip. Ubuntu packages are not agile enough to follow the faster release cycles of many Python packages.

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.

Django - Mac development, environment hell

I was trying to setup Django dev environment on Mac and arrived into a hell. It all started when trying to install PIL, which failed after trying 15 or so different recipes I found on blogs. So I wanted to install the Python, this time 2.7, and reinstall setuptools, easy_install, pip from scratch.
After just installing Python 2.7, and easy_install with setuptools for 2.7, this all in turn created such a mess that is unbelievable. Different version of Python are installed everywhere, easy_install is installed everywhere and points randomly to different python hashbangs (sometimes to #!/usr/bin, #!/usr/local/, #!/Library/...)
Now I can't even do easy_install pip, which I always could. So I'm already in a hell and I haven't even attempted to install MySQL yet.
My question finally is did anyone bump into such problems, it would help enough to know that I'm not alone.
Second, would it be easier to set up the entire environment on Ubuntu than it is on a Mac?
Thirdly, is there any guide that can really clearly explain how to set up but also tear down the stack for Python development on a Mac?
It wouldn't hurt to run a VM with vagrant. This post should tell you more:
http://stevelosh.com/blog/2011/06/django-advice/
Of course using virtualenv should also help alleviate some of these issues.
I've gone through the same hell 2 weeks ago :)
I needed to make working python 2.7 and virtualenv on OSX 10.6.8.
You haven't mentioned virtualenv in your question but I strongly recommend it. That way you minimize amount of globally installed packages. Everything is... cleaner.
My idea is to only have following things globally:
python (from brew)
pip (via easy_install)
virtualenv (via pip)
virtualenvwrapper (via pip)
other through either virtualenv or buildout
I've just checked and pip PIL installs fine within my virtualenv.
Here are notes from this battle (gist.github.com):
#NOTE: .pydistutils.cfg seems to be not compatible with brew install python
#areas I needed to clean before installation
#clean up ~/Library/Python
#clean up .local
brew install python
easy_install pip
pip install virtualenv
pip install virtualenvwrapper
mkdir $HOME/.virtualenvs
Example .bash_profile:
#homebrew
export PATH=/usr/local/bin:/usr/local/sbin:${PATH}
# homebrew python 2.7
export PATH="/usr/local/share/python:${PATH}"
#virtualenv wrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/share/python/virtualenvwrapper.sh
Good luck!
Second, would it be easier to set up
the entire environment on Ubuntu than
it is on a Mac?
To answer this question (though I never used Mac though): I never had problems setting up a python environment for Django development on Ubuntu. Though in any case you should go with the built-in Python version if possible. Attempting to install any other Python versions usually ends up messy. Luckily with Ubuntu 11.04 the standard version is already 2.7.
I'm using django development environment on a MAC OS X 10.8 with python 2.7. I don't use virtualenv ore some other things.
With all the respect can say that there is NO ANY PROBLEMS to develop on a mac. Mac is a UNIX like system and you've probably seen that all tools for developers have MAC ports.
As for the setup mess. It's a good idea to use virtualenv. As for PIL installation. I needed to compile it with TrueType. As I'm in common with UNIX like environments it was not heavy task for me to compile PIL from sources using GCC (it's already installed on a MAC)... There are some mess with Django to setup virtualenv... There are certainly lots of articles to setup it on Google.
I use Eclipse and write all my PYTHONPATH variables there. You can forget installing everything like in Linux and try not to make anymore mess with installed tools. Try to read THIS article if you feel like you're ok to use Eclipse for your development on a MAC. It also has a recipe to avoid mess with installation of many copies of Python and other dev utils.
Yes I have had problems with MacOS. I think rather than trying to figure it out I just switched to Ubuntu. I use a mac with Ubuntu installed in VMware Fusion. I have developed on both and prefer the Ubuntu because I'm just more comfortable with installing packages and the file structure.
I love using the VM because I'm never scared of having to start over. I can get a whole new OS installed and get the packages with what I use in just a few hours. Not to mention with 6month rollouts I can do complete installs of new versions instead of updates.
Depending on your production environment, it may be beneficial to use an OS that is similar, if you can install a package on ubuntu desktop, you already know how to do it on ubuntu server.

using python 2.6?

i have no way of upgrade to python 2.7 or 3.1 so i am stuck with python 2.6 on my ubuntu 10.04 machine.
will i still be able to find host that supports python 2.6?
is using python 2.6 still consider outdated or bad practice?
2.6 will be around for a long time. There are many machines that still run even 2.4, so you're fine.
Python 2.6 will probably still be around for a while, as Python 2.7 was released only a few months ago.
You can always use from __future__ import ... to make use of some of the newer features from Python 3.x
will i still be able to find host that
supports python 2.6?
Yes. No problems whatsoever.
is using python 2.6 still consider
outdated or bad practice?
No, it is not.
However:
I have no way of upgrade to python 2.7
Yes you do. You download the source code from www.python.org and install it.
What you should be careful to do in not to overwrite the system Python.
Install it either with "altinstall" (will not override the system python) or even better,
use a custom prefix. For example:
$ ./configure --prefix = /opt/python27
$ make
$ sudo make install
It is often a good idea to use a separate Python install for development, as you can do whatever you want with it including deleting it and reinstalling it without affecting the system Python.
You are NOT stuck. :)
I'm Using Ubuntu 10.04 as well I have Python 2.3.7, 2.4.6, 2.5.5, 2.6.6, 2.7.1, 3.0.1, 3.1.2 and 3.2b2+ installed. No problems. Yes, I use all of them, even though it's mostly 2.4 and 2.6.
Python3.1 is in the repositories for 10.04
$ apt-cache show python3
Package: python3
Priority: optional
Section: python
Installed-Size: 76
Maintainer: Ubuntu Developers <ubuntu-devel-discuss#lists.ubuntu.com>
Original-Maintainer: Matthias Klose <doko#debian.org>
Architecture: all
Source: python3-defaults
Version: 3.1.2-0ubuntu1
Depends: python3.1 (>= 3.1.2), python3-minimal (= 3.1.2-0ubuntu1)
Suggests: python3-doc (>= 3.1.2-0ubuntu1), python3-tk (>= 3.1.2-0ubuntu1), python3-profiler (>= 3.1.2-0ubuntu1)
Filename: pool/main/p/python3-defaults/python3_3.1.2-0ubuntu1_all.deb
Size: 11096
MD5sum: 81f3f3bf790f5d7756b76c8d92fcea86
SHA1: 32e12dc7f9500456e063f22645c1cfed76b8845c
SHA256: 0f541352ace2fcf1929a93320ffbe2f1de4e1d140bbe70a7c5a709403b73341c
Description: An interactive high-level object-oriented language (default python3 version)
Python, the high-level, interactive object oriented language,
includes an extensive class library with lots of goodies for
network programming, system administration, sounds and graphics.
.
This package is a dependency package, which depends on Debian's default
Python version (currently v3.1).
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 3y

Is it possible to run two versions of Python side-by-side?

I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5.
Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.
Absolutely.
If you're on *nix, you'd usually just use make altinstall instead of make install, that way the "python" binary won't get installed/overwritten, but instead you'd have e.g. python2.5 or python2.6 installed. Using a separate --prefix with the configure script is also an option, of course.
Some Linux distributions will have multiple versions available via their package managers. They'll similarly be installed as python2.5 etc. (With the distribution's blessed/native version also installed as the regular python binary.)
Windows users generally just install to different directories.
Yes, it is possible to install multiple versions of Python "side-by-side".
On Ubuntu, you simply install with
sudo apt-get install python2.5
(On the current version of Ubuntu, 10.04, python2.6 comes installed by default.)
To use python 2.6, just call python or /usr/bin/python.
To use python 2.5, you call /usr/bin/python2.5.
If you tell us your operating system, we may be able to provide more relevant details.
Another possibility is to use virtualenv.
OK, I figured out the answer to my own question, partly with the help of Nicholas Knight who pointed out that you just install different Python version to different Python directories. I was left scratching my head on how to get Google App Engine to use Python 2.5 (the required version) instead of Python 2.6. This is the answer:
1) Install Python 2.5.
2) Install Python 2.6 (or a more recent version), afterwards. This will be the system default.
3) Install the Google App Engine SDK.
4) Launch, "Google App Engine Launcher" from the Start Menu
5) Click Edit > Preferences, and enter the path to the pythonw.exe executable. Usually c:\Python25\pythonw.exe

Categories

Resources