Disclaimer:
The following suggestions assume that you have installed Python independently on your system and not as a required part of any other program installation.
It assumes you are using "vanilla" Python from python.org
and not any specialized Python bundle or Python from the Windows Store.
This should not affect Python under WSL as far as I am aware, but that is a supposition.
The suggestions below are generic and it sounds like you may have tried at least some of them, but it is often good to cover all the bases. =)
General Suggestions
Remove Your Existing Environment Variables
Delete all the environmental variable references to Python in your screenshot. This includes:
C:\Users\Owner\AppData\Local\Programs\Python\Python38\Scripts
and any other refrences under your User PATH
variable
As well as all the references in your System Path
(as shown in your screenshot):
C:\Windows;C:\Windows\System32;C:\Python39
C:\Users\Owner\AppData\Local\Programs\Python\Python39
C:\Users\Owner\AppData\Local\Programs\Python\Python38
C:\Users\Owner\AppData\Local\Programs\Python\Python38\Scripts
At best, only two of these would work from the command line directly (one of your Python39 references for python
and one of your Python38 Scripts
reference for pip
) and these aren't even related to the same installation, so they cannot work together for installing modules correctly.
If you want to keep the general C:\Windows;C:\Windows\System32;C:\Python39
entry, that is up to you, but you should remove the C:\Python39
portion. That said, I believe C:\Windows
and C:\Windows\System32
are probably redundant in this case, since they should likely be covered by %SystemRoot%
and %SystemRoot%\system32
respectively.
Note that you can certainly keep the entries you remove aside (e.g. in Notepad) in case something breaks, but overall, unless another program relies on them, your current layout is not generally the way to handle multiple Python installations on Windows.
Add One Installation Back
There two ways to approach this. First, you can simply pick an existing installation you would like to access from the command line and add it back to your environment variables (I would recommend using your System Path
variable rather than your User PATH
). So:
C:\Python39
C:\Python39\Scripts
or:
C:\Users\Owner\AppData\Local\Programs\Python\Python39
C:\Users\Owner\AppData\Local\Programs\Python\Python39\Scripts
or:
C:\Users\Owner\AppData\Local\Programs\Python\Python38
C:\Users\Owner\AppData\Local\Programs\Python\Python38\Scripts
Reboot before testing python
or pip
from the command line.
If this doesn't work for some reason (or you want to ensure a minimal number of potential issues in the future), I would suggest uninstalling Python (again) from C:\Python39
and both copies of Python (3.8 and 3.9) from your Users
folder.
Afterwards, pick one copy of Python to be your primary installation available from the command line and try following these installation guidelines I wrote for another question. I would be particularly aware of using a custom folder and avoiding C:\Programs Files
, C:\Program Files (x86)
or anything under Users
for this installation (these can all potentially cause problems).
Notes
You can add more Python installations to Windows later, if you so choose. That said, while there are ways to use more than one Python version at a time from the command line, only one Python version can technically be available with python
and pip
at a time.
Be aware that Python does not behave like many others Windows programs in that installing a new version will not "upgrade" prior versions. You will simply have two (or more) installations of Python.
As a general recommendations, Python 3.8 is probably the best Python version to install at this point, since many modules are moving to it. However, for maximum compatibility regarding modules, you may want to consider Python 3.7 (version 3.7.7 currently). I would say Python 3.9 likely doesn't have many modules available for it right now, so unless you have a compelling reason to install it, it probably isn't the best option as of this writing.
Edit
Is there a way to just download new packages without pip?
Yes. But as fair warning, while certain modules can be simple to install (assuming you intend to do this), others can be relatively time-consuming (or worse).
The modules that pip
accesses are all downloaded from the Python Package Index. Each "project" (module) hosted there has an individual page that has a Download files
link for the files hosted on PyPI and (possibly) a Download
link if an author has provided an alternate source to download the project files from:
ex. PyPI Project (Module) General Links
ex. PyPI Project (Module) File Links
As a caveat, while some modules may not have any dependencies, some modules rely on other modules to operate correctly. Unfortunately, it isn't always easy to discover what dependencies a module might have without additional research.
Another pitfall is that some versions of the same modules may only be intended for certain platforms (e.g. Linux, but thankfully these are often marked appropriately).
All I want is to be able to get the last modules I need for my code so I can send it off[.]
pip
is probably the last tool you want try using right now, but to be clear, pip
does not have to be directly available from the command line as just pip
(via your environment variables) to be used to collect or install packages correctly.
Based on your comments, assuming you chose to install pip
with Python 3.7 (pip.exe
is present in C:\Python37\Scripts
), you should be able to access pip
for your Python 3.7 installation one of two ways:
C:\Python37\python.exe -m pip example-command
or directly as:
C:\Python37\Scripts\pip.exe example-command
With vanilla Python on Windows, environment variables are generally not required to actually run python.exe
or pip.exe
successfully for a single Python installation.
Batch Helper
Just a thought, but if you don't care to type long paths and can execute .bat
(batch) files from the command line, you may want to consider creating a "helper" batch file e.g.:
ex. fake-pip.bat
C:\Python37\python.exe -m pip %*
This could allow you easier access to pip
from any folder with that batch file in it.
Full disclosure: It is still possible to get an error similar to the ones your seeing above if you try to execute ex. fake-pip
in a directory that doesn't contain this batch file.
Otherwise, as long as you are careful about keeping this batch file wherever you are working on the command line, you should be able to side-step the "not found" issue you are encountering above.
fake-pip.bat Examples
For instance, to install a module into Python 3.7 with fake-pip.bat
, you should be able to open a command window in the same folder and use:
fake-pip install module-name
to install that module correctly into Python 3.7.
Note that if you want to simply have a copy of the module and its dependencies on your PC (ex. to put on a disk and give to someone else), you can instead use the download
option for pip
:
fake-pip download module-name1 module-name2 ...
path
instead of%path%
. By the way, is python really there in the folder C:\Users\Owner\...\Python39? And is the executable namedpython3
andpip3
instead ofpython
andpip
?PATH
is malformed (only one entry per line via GUI), which means the one with three on it is incorrectly separated when viewed as single line of text, and it appears you're also missing several SystemPATH
default paths. There's only two things that would cause the issue you're experiencing, either (1) The SystemPATH
has had a path incorrectly added to it (which your screenshots show); or (2) all shell Windows have not been closed to update the shell with the new path value(s).