On my Mac OS X 10.9 Mavericks machine, I have installed Python 2.7.6, PySide 1.2.1 and mysql-python 1.2.3 (all of them installed using Homebrew and Pip). Since I edited the /etc/paths to begin with /usr/local/bin before installning anything, all of the modules have been installed in /usr/local/lib/python2.7/site-packages and 'which python' returns /usr/local/bin/python. Everything runs smoothly.
Is it possible to somehow copy these modules onto a server location, for other OS X machines to import (rather than install this locally on all other OS X machines)?
I strongly suggest using Virtualenv to manage your Pip packages.
It allows you to:
site-packages
used by various projects; site-packages
provided by the OS, so that you don't have a conflict when moving from an OS X workstation to a Linux server; requirements.txt
file with the exact names and versions of all libraries installed in the Virtualenv of any given project (this file will be committed to your source repository) and finally:
Granted, some of these features are provided by Pip, but Virtualenv puts them all into a failsafe environment.
So i have a couple of modules installed in a virtualenv, but how do I put them in a server location, and can they be read/imported without running a virtualenv on the other machines?
You mentioned some modules, such as mysql-python, which need to be compiled into a binary module. They cannot be ported between different machines.
Other modules, which are of Python files only, can indeed be copied over to the other machine's site-packages
. But even for those, it's best to use a virtualenv, instead of putting random junk into a server's site-packages
directory.
In the server location you should install a clean virtualenv (using the right version of Python, of course) and then install all the required modules from source, using a requirements.txt
file:
$ mkdir ~/virtualenv
$ python2.x virtualenv.py ~/virtualenv/your_app
$ ~/virtualenv/your_app/bin/pip install -r requirements.txt
The virtualenv path is just a suggestion. You can produce the requirements file from your current machine:
$ pip freeze > requirements.txt
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.