python development environment on a mac

Mojca Miklavec mojca at macports.org
Tue Mar 14 11:20:00 UTC 2017


On 13 March 2017 at 14:28,  <macports at parvis.nl> wrote:
> my son needs for his music studies a python development environment 2.7.13 plus the actual 3.x.
> his imac is on osx 10.11 el capitan.
>
> so i installed from macports python 27 and 33, ipython, selects:

You mean Python 3.6?

> questions:
> - should i install ipython in this virtualenv
> - if so, how (macports or not)?
>
> questions:
> - does virtuelenv36 uses 2.7 dus to port --select?

I don't understand this question.

> - if so, how should i have done it?
>
> the big question: please explain to me the relation between macports python/ipython/pip/virtualenv and how i should use it? when & how macports, when & how not, why???

I'm not able to answer all of your questions, but you probably want to run
    sudo port select --set python2 python27
    sudo port select --set python3 python36
    sudo port select --set python python27

so that python, python2 and python3 will launch the desired version of
Python (you can change the versions according to your needs),
otherwise "python" will launch the system python.

Generally I would say that if python packages from MacPorts satisfy
your needs, it's probably better to stick with Python shipped by
MacPorts and not use virtualenv at all (and use "sudo port install
py27-whatever" rather than "pip-2.7 install whatever" or "pip install
whatever").

Virtualenv is particularly important when using an "ancient
distribution". (A lot of things become "ancient" pretty soon. Even the
latest stable linux distribution might provide packages that are a few
years old due to their strict release policies, while you might want
to use either the bleeding edge version of a package (maybe because
you filed a bug report that's blocking your work and they fixed the
error, but didn't even provide a new release yet) or because the
software you want to use no longer works with the latest package and
you need an older one.

Your son might get instructions telling him to run "virtualenv ... &&
pip install foo bar whatever". When using MacPorts, those commands
should be slightly altered (you would want to find the suitable
package), but in most cases the result should be perfectly fine. Only
if some problems arise that cannot be addressed by MacPorts (or if the
person doesn't know how to adapt the installation commands and doesn't
want to bother), then it makes sense to use virtualenv.

If some packages are missing, you could also request them.

Mojca


More information about the macports-users mailing list