python development environment on a mac

Joshua Root jmr at macports.org
Tue Mar 14 16:54:49 UTC 2017


> $ which virtualenv
> /opt/local/bin/virtualenv
> $ virtualenv $HOME/PyEnv/python/27
> New python executable in /Users/paul/PyEnv/python/27/bin/python
> Installing setuptools, pip, wheel...done.
> $ virtualenv $HOME/PyEnv/python/36
> New python executable in /Users/paul/PyEnv/python/36/bin/python
> Installing setuptools, pip, wheel...done.

I notice you ran 'virtualenv' here both times, which is linked to 
virtualenv27.

> $ ls /$HOME/me/PyEnv/python/*/bin
> /$HOME/me/PyEnv/python/27/bin:
> activate		activate_this.py	pip			python			python2.7
> activate.csh		easy_install		pip2			python-config		wheel
> activate.fish		easy_install-2.7	pip2.7			python2
> /$HOME/me/PyEnv/python/36/bin:
> activate		activate_this.py	pip			python			python2.7
> activate.csh		easy_install		pip2			python-config		wheel
> activate.fish		easy_install-2.7	pip2.7			python2

So this is not surprising given the above. If you want a python 3.6 
virtualenv, use virtualenv36 (or whatever the 3.6 version is called).

> 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???

Well, IPython is a python module that provides an enhanced interactive 
shell for python. Pip is the official python module installer. 
Virtualenv is a system for making isolated python environments.

MacPorts manages most of the things that pip does itself, so you 
normally shouldn't use pip to install modules into the macports prefix. 
It's fine to use it to install into a separate location (e.g. in your 
home directory) or into a virtualenv.

Use a virtualenv when you want a python environment containing a 
specific set of modules for a certain task. The documentation has more 
info: <https://virtualenv.pypa.io/en/stable/>

- Josh


More information about the macports-users mailing list