Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I wanted to use the 32 bits python because I need a module that only works with the 32 bits version, but I don't want to use the 32 bits version always, but when I run a script, it runs with the 32 bits version, always. What can I do to only use the 32 bits sometimes, and leave the 64 bits for default use?

share|improve this question

migrated from stackoverflow.com Jun 13 '13 at 7:46

This question came from our site for professional and enthusiast programmers.

    
If you know how to fix your PATH or configure your Python loader, do that. If not, just reinstall the 64-bit version, and the installer will do it for you. –  abarnert Jun 13 '13 at 0:16

2 Answers 2

up vote 2 down vote accepted

There are four different ways that Windows chooses which Python to run.

  • If you type python or python foo.py at a DOS prompt, it goes by which one is found first on the PATH. Normally, the installer for each version puts that version at the start of your PATH, so whichever one you installed last wins.
  • If you double-click foo.py in Explorer, it goes by Explorer's file type association mapping. Normally, the installer sets the association to its version, so again, whichever one you installed last wins.
    • If the latest one you installed was new enough to have the "Python Windows Launcher", it will actually set that, rather than Python itself, as the Explorer mapping. The launcher will first look for a Unix-style #! line at the top of your script and run whatever's specified there.
    • If you have the launcher, and your script doesn't have a #! line (or has a Unix-specific one that doesn't work for you), it will look in a whole slew of places (most importantly py.ini) to decide which one is the default. Again, normally, the installer sets the default to its own version… unless you already had a strictly higher version.

So, the best thing to do is to learn how all of this works and edit your PATH, Explorer association mappings, and all of the relevant stuff for the launcher.

See PEP 397 for the full details on new-enough versions and as-good-as-you're-going-to-find partial details (in the Rationale section) on older versions.

But the easiest thing to do is to re-run the 64-bit installer, make sure to leave on all the checkboxes, click OK if it asks something like "are you sure you want to override the existing settings", and your 64-bit Python will be the default again.

Or, if you've installed a GUI IDE (other than IDLE), many of them have an option somewhere in the menus to "give me a list of all installed Pythons and set the one I choose as the default" (or, for the ones written in Python, possibly just to "set this Python as the default").

share|improve this answer
    
+1 Your answer is better than mine :-) –  Jonathon Reinhart Jun 13 '13 at 0:27
    
I reinstalled the 64 bits version and it became the actual version, but I don't know how to use the 32 bits version when I want to :( –  Lucas Zanella Jun 13 '13 at 0:48
    
@LucasZanella: You still have to tell us what you're trying to do when you say "use". Are you double-clicking the script in Explorer, or double-clicking Python itself, or dragging scripts to a Python icon? Typing python foo.py in a DOS window, or just foo.py? Or something entirely different? Also which version(s) do you have? (I can't guess whether you have the launcher by reading your mind.) –  abarnert Jun 13 '13 at 0:54
    
@abarnert I want to ALWAYS use the 64 bits version when: I open an script with the explorer, and when I run de F5 of the IDLE. But I wanted to run the IDLE only SOMETIMES for the 32 bits version. So I want to: always use the 64 bits version, in anywhere, no matter what. But sometimes use the 32 bits version in the IDLE. Only it. (the two versions are the 3.3) –  Lucas Zanella Jun 13 '13 at 1:02
    
OK, you actually have two copies of IDLE now, the default 64-bit one, and the 32-bit one. Each one can only run scripts for its version of Python. So, when you want to run a 32-bit script, launch the 32-bit IDLE, and run the script from there. They're in different folders (e.g., C:\Python27_64\Scripts\IDLE.exe and C:\Python27\Scripts\IDLE.exe). Hopefully they also have separate submenus under the Start menu, etc.; if not, make whatever shortcuts make you happy. –  abarnert Jun 13 '13 at 1:18

Change your PATH to point to the 64 bit version, or re-install the 64-bit version so that it becomes the default.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.