12

I have decided to learn generic algorithms recently and I needed to install Tensorflow package. Tensorflow run on python 64 bit only, so i install python 3.5.0 64 bit without uninstalling python 32 bit. because i was afraid to lose my packages on python 32 bit by uninstalling it. The problem is how can i force pip install to install a package on my python 64 bit version instead of 32 bit version.

5
  • it's windows 10 Apr 16, 2017 at 5:31
  • but i have both of them now. i have 2 options editing IDLE on 32bit and 64 bit Apr 16, 2017 at 5:32
  • yes both of them run properly but 64 bit does not have the packages i had installed on 32 bit already Apr 16, 2017 at 5:35
  • That's fine, just checking, try the method in Ashish's answer, it will work if it's installed properly
    – Taku
    Apr 16, 2017 at 5:35
  • my previous 32 bit was installed on C:\Python and my newly installed 64 bit python is installed on C:\Users\office\AppData\Local\Programs\Python\Python35 .I'm not sure if python has decided to change the default install rout to this path nowadays or python had detected i had 32 bit version already and choose a new path to install Apr 16, 2017 at 6:12

6 Answers 6

14

If you have actually managed to install both x64 & x32 packages, you could simply do

C:\path\to\corresponding\python.exe -m pip install <package>

This will ensure you use the correct pip and install the package for the specific python instance.

7
  • 1
    On command Prompt i cd to the corresponding folder(pathon 64 bit) and then pip install the package. unfortunately it didn't work Apr 16, 2017 at 5:48
  • You can check which pip version you used by checking pip -V. And like I have mentioned, just use the correct python.exe instead of trying to use the correct pip. Apr 16, 2017 at 5:51
  • Wow it's working. Tyvm!!i had to upgrade my 64bit pip at first to install my desire package Apr 16, 2017 at 6:01
  • by the way what does that -m mean? and do you know if i uninstall python 32 bit and reinstall it later, the packages will be deleted too? Apr 16, 2017 at 6:02
  • 1
    @MohsenHaddadi The -m stands for module. And yes, uninstalling python itself will surely remove all the packages too. If you want to reinstall all packages, just make a note of all the packages by doing pip freeze > \path\to\backup\requirements.txt. So, if you want to reinstall later, you can just do pip install -r requirements.txt. Apr 16, 2017 at 6:06
8

Starting with Python 3.3, coexistence is made much easier with the Python Launcher for Windows. (Also see PEP 397.) From the command line you can use "py" or "pyw" in place of "python" or "pythonw". The py command allows you to specify the revision and version of python to run. For example, open a command window and type in "py -3". This runs the latest revision of python 3 available and defaults to the 64 bit version if it is available. On the original poster's system, entering this command will start the python 3.5-64 bit interpreter.

This command can also be used to run the correct version of pip without knowing the exact path to the python version you want to install to. "py -3.5 -m pip install [package]" will install [package] to the 64 bit version of python3.5.

If you have both the 64 and 32 bit versions installed and ever need to install to the 32 bit version, you have to enter both the major and minor revision numbers as part of the command and add '-32' to the command argument. "py -3.5-32 -m pip install [package]" will install to the 32 bit version.

1

If you do have both the 64 and 32 bit versions installed and need to install a 32 bit version package only, you have to enter the target -t (32 bit Lib) with pip3, e.g. install bitcoin lib:

 pip3 install -t C:\Users\
       max\AppData\Local\Programs\Python\Python36-32\Lib bitcoin
0

I have both 64 and 32 bit python environments on my machine.

To build targeting 32 bit or 64 bit, i edit the environment variables setting the PATH for the whole python installation and one environment variable pointing to the scripts area, where pyinstaller is.

.....\Continuum\anaconda3_32bit
.....\Continuum\anaconda3_32bit\Scripts
 or 
.....\Continuum\anaconda3
.....\Continuum\anaconda3\Scripts

The I run pip install pyinstaller (which uses the PATH to find the required versions of PIP and pyinstaller).

The app must have been built using the correct python environment as well.

0

As an additional solution it's good to know that windows (or any) operating system looks for apps firstly in current directory then check path environment variable. So it's a good idea to place preferred python version's path to first position in path env variable. Or simply replace the old pythons's path with new one.

-2

There's nothing much you can do. I also had this issue. The best thing to do is to change your python path and install the packages on the 64 bits python.

3
  • Instead of changing python path, the easier way is to open command prompt on 64 bits python.exe directory and then type and run 'python pip install ...' Nov 2, 2020 at 7:51
  • That won't work. You would be doing that foer only the current pip version (either the 32 bits or 64 bits). The only way I know us just as I said Nov 3, 2020 at 20:25
  • Are you sure you have type and run 'python.exe pip install ...' after typing and running 'cd c:\ desire python version directory' on windows command prompt? Nov 4, 2020 at 13:48

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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