Since I replaced the machine, I stumbled on various things when I built the Python environment for the first time in a while, so make a note.
http://d.hatena.ne.jp/nakamura001/20111129/1322579170 http://www.sicafe.net/macPackageManageTips/html/homebrewPythonInstall.html http://yono.hatenablog.jp/entry/20100923/1285235346 http://mzmttks.blogspot.jp/2011/12/python-site-packagesdist-packages.html http://hello-hello-world.blogspot.jp/2011/09/pythonsite-packages.html
Python is installed by default on Mac.
However, when building a development environment, I don't want to pollute the standard environment, or I need a different version of Python, so I often install it separately.
However, if you do a half-finished setup, the library installation destinations will be mixed unintentionally when installing the library, and the package you should have installed may be missing.
easy_install is already included
/usr/bin/easy_install
But pip was installed from the official installer
/usr/local/bin/pip
It's sloppy. Furthermore, if Python is under / opt, it will be even more chaotic.
For example, the standard python site_packages are:
/Library/Python/2.7/site-packages
For python installed with MacPorts, it will be as follows.
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Well, basically, if you use it only in virtualenv, there will be no problem.
This is a case of creating an environment for Python using MacPorts, aside from the details, as it involves historical issues specific to Python.
First of all, python body
$ sudo port install python27
1. Then easy_install. For some reason setuptools doesn't support select, so easy_install uses a command like easy_install-2.7 to match the destination python.
```bash
$ sudo port install py27-setuptools
If an error occurs here, it will appear in the error log, but you can fix it with the following command. By the way, in my case, it occurred in the environment after executing the official get_pip.py with python that was put in the port.
```bash
sudo port -f activate py27-distribute ```
Next, put pip in port as well. Switch between standard pips with select.
$ sudo port install py27-pip $ sudo port select --set pip pip27
1. Virtualenv relationship.
```bash
$ sudo port install py27-virtualenv py27-virtualenvwrapper
$ sudo port select --set virtualenv virtualenv27
$ echo -e "\n# virtualenv\nexport WORKON_HOME=\$HOME/.virtualenvs\nsource `which virtualenvwrapper.sh-2.7`\n" >> ~/.bashrc
Virtualenv can be switched with select. Note that virtualenvwrapper does not have select.
How to find out the path referenced by python
python -c "import site; print(site.getsitepackages())"
Reference to distribute
python -c "import distutils.sysconfig as s; print(s.get_python_lib())"
Recommended Posts