0

I'm trying to install multiple python versions on Windows as I need a 32-bit and 64-bit version. I currently have python 3.7 32 bit installed and am trying to get python 3.9 64-bit working (although I tried this with 3.8 64-bit as well, getting me the same results).

Installing via the executable files provided via python.org does no give any issues, expect that pip doesn't seem to be installed properly. When checking the pip install via pip3.9 -V, I get 'pip3.9' is not recognized as an internal or external command, operable program or batch file. even though I have set the environment variables for this new python install.

When I check the python install, it starts to make sense that it has troubles finding pip, as it isn't installed in Python39\Scripts. However, when I manually try to install pip using py -3.9 get-pip.py, I get another error:

Traceback (most recent call last):
  File "<user>\get-pip.py", line 24, in <module>
    import pkgutil
  File "<user>\AppData\Local\Programs\Python\Python37-32\Lib\pkgutil.py", line 5, in <module>
    import importlib
  File "<user>\AppData\Local\Programs\Python\Python37-32\Lib\importlib\__init__.py", line 51, in <module>
    _w_long = _bootstrap_external._w_long
AttributeError: module 'importlib._bootstrap_external' has no attribute '_w_long'

This traceback indicates that, even though I'm calling py -3.9, it is using libraries from my python 3.7 install. The same error pops up when running py -3.9 -m pip --version or py -3.9 -m ensurepip --upgrade.

Related stackoverflow questions (here and here) haven't been able to help as they seem to run into the same error in a different situation.

Any help would be appriciated!

1 Answers1

0

Installing multiple versions of python next to each other is a slippery slope in my experience. Make sure all your python versions can be found (they should be in your shell's $PATH variable). If you want to call pip that needs to be in $PATH too. All versions of it and properly configured for all the names of all the versions of python you have installed.

In my experience it is much easier to call pip as a module from python directly, which is now, for installing packages at least, the preferred way anyway.
$ python3.9 -m pip //whatever you wanna do with pip

If you want to work with different setups side by side, you should look into virtual environments. Quite easy to setup and they keep everything nice and organised.

noranraskin
  • 1,127
  • 8
  • 17
  • Both python versions and the 3.7 pip folder are part of the path. For the 3.9 pip, there is no folder to point to. Using pip as a module in python gives me the error shown in the traceback. This is also the error I get when I try to make a venv in 3.9. (In general, can a venv help when needing two python version? Isn't a venv created from an existing python install?) – Tom Janmaat Jan 29 '21 at 08:29