问题
I'm moving from a computer with windows xp to one with windows 7 (64 bit) and I want to install Python on the new machine. I'm currently using python 2.7 and 3.2 and a bunch of packages
1) Should I install the 64 bit versions?
2) How can I tell which packages I currently have, so that I can get those for the new machine?
If these are duplicates (my search skills seem to be failing), please point me to the threads where they're discussed.
回答1:
Type help('modules')
of the Python shell to get a list of all installed modules. If you can find stable 64-bit versions, then by all means select 64-bit builds for installations.
回答2:
From your Python home folder go to ../Lib/site-packages/
and save the folder listing to a file, e.g. ls > ~/my-python-modules.txt
on Linux/OSX, or dir > my-python-modules.txt
on Windows. The file will contain all the additional modules that have been installed on your system. Also, from the same folder search for *.pth
files: they might contain the names of modules that were installed as Python Eggs.
On Linux/OSX the location of the site-packages
folder might vary: use locate -b site-packages
to quickly find out where they are.
To reinstall the modules it is best to use your system's built-in package manager if it has one (this will be the case if you use Linux or MacPorts), otherwise you will need to use easy_install
(the package is called setuptools) or pip
(url). On Windows with modules that need C/C++ compilation it is easiest to use binary executable installers, unless you have a sane build environment like MS Visual Studio or MinGW. If you install binary packages then it is probably best to get the 64-bit version to match your architecture. Not sure if 32 bit versions will work or will event install.
回答3:
You can use pip now for this purpose.
using pip list
will give you a list of the packages that you have installed and the versions.
You could also use pip freeze
and then copy the output of this to a file and then use this as a requirements files so you can install those exact modules and versions again on the new computer.
More information on pip is here is here
but to install from a requirements files you would use
pip install -r requirements.txt
来源:https://stackoverflow.com/questions/8636386/python-moving-to-a-new-computer