简体   繁体   中英

Windows 7 with multiple python version, how to install the same package for different version?

I have python 3.4.1 and 2.7.8 installed on my Windows 7 Ultimate 64 bit OS. Now I want to try ipython (download the binary version from http://www.lfd.uci.edu/~gohlke/pythonlibs/ ). The two files (I want to try ipython for both my python 2 and python 3) I will download are:

  • ipython‑2.2.0.win32‑py2.7.exe
  • ipython‑2.2.0.win32‑py3.4.exe

I want to know what is the correct way to install them. Is it enough for me to just click those 2 files and next next ... next close? Will those installers find the correct python version by themselves?

As @EdChum mentioned, virtualenv is a fantastic way to play with different distributions. This method is outlined here .

As for your second question, what will ultimately happen (in Windows) if you simply install several versions using the Windows installers, is that multiple folders will appear in your install path (typically your OS partition, eg C:). The Python instance that is used when you type 'python' depends on which executable is associated with your PATH. This can cause problems because you may not be sure which, or have forgotten which Python is being referenced, resulting in undesired and unpredictable behavior. If you want to get into the nuts and bolts of which python is executing your .py files, this is a great place to start.

A quick way to find which python is currently being executed is to run python in your CMD shell or from your RUN prompt, and read the version.

I've run 3-4 different Pythons on my Windows machine at once. For the most part, when you run an installer that is directly tied to a specific version of Python, it will indeed install correctly against that version. Sometimes you will see a package named something like "myPackage-1.0.win32.exe". When you run one of those, there will be a step in the installer that asks you which Python you want it to install against.

You could also just use virtualenv as that allows you to try out various Python packages in a virtual environment instead of cluttering up your main installation. This can be invaluable if you are needing to test a newer version of a package but you don't want to break your current setup.

Note: I have noticed that when having multiple Python versions installed, the default Python is usually the last one that I installed. You may have to edit your path or run Repair on the Python that you want set as your default.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM