1

I've downloaded and uninstalled Python so many times trying to get this to work. No matter what happens I always get:

"'python' is not recognized as an internal or external command, operable program or batch file."

All I want to do is download new modules with PIP. I’ve tried the suggestions on so many forums.

My environment variables has this in both User and System variables:

"C:\Users\Owner\AppData\Local\Programs\Python\Python38-32\Scripts"

Nothing has worked. Computer has been restarted many a time. Python redownloaded many a time. Has never worked.

Even in the autonomous WinPython command lines and IDLE i cannot access python in its command line.

Added picture of my environment variables and my Command Prompt Responses

10
  • 2
    To check the path settings, just type path instead of %path%. By the way, is python really there in the folder C:\Users\Owner\...\Python39? And is the executable named python3 and pip3 instead of python and pip?
    – Kenneth L
    Jun 18, 2020 at 1:51
  • C:\Users\Owner\AppData\Local\Programs\Python\Python38-32 is where the installer keeps naturally wanting to place it (despite the fact you cant get into AppData or see that folder without typing this whole big ugly line), in there is all the stuff it normally downloads with. In its Scripts folder is pip, pip3, pip3.8, easy_install, and easy_install-3.8
    – Chad
    Jun 18, 2020 at 1:57
  • python.exe confirmed in folder C:\Users\Owner\AppData\Local\Programs\Python\Python38-32
    – Chad
    Jun 18, 2020 at 1:57
  • Will you want to try to split the line "C:\Windows;C:\Windows\System32;C:\Python39" in the "Edit Environment Variable" window into three lines?
    – Kenneth L
    Jun 18, 2020 at 2:02
  • 2
    Your system 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 System PATH default paths. There's only two things that would cause the issue you're experiencing, either (1) The System PATH 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).
    – JW0914
    Jun 19, 2020 at 14:25

2 Answers 2

5

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

PyPI Project (Module) Links - Screenshot

ex. PyPI Project (Module) File Links

PyPI Project (Module) Links - Screenshot

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 ...
6
  • 2
    Very nice answer. Not just the simple solution (fix your path) but also explains why it has to be setup like that.
    – Tonny
    Jun 18, 2020 at 17:44
  • Great answer. Thank you so much for all the detail. Sadly this still didn't work. First tried setting path to only a select 2. Rebooted and didn't work. Then I deleted all again and deleted all the python files i could and reinstalled. I saved it to C:\Python 3.7 and the setup automatically added it to path. Rebooted. Attempted to open python and run anything related to pip or python in command line...same message as always.
    – Chad
    Jun 19, 2020 at 2:20
  • Is there a way to just download new packages without pip? Or an interactive shell separate from my computer that still lets it affect my computer? All i want is to be able to get the last modules i need for my code so I can send it off to my supervisors, don't care if command line wont accept me for who i am.
    – Chad
    Jun 19, 2020 at 2:21
  • @Chad You're welcome. It's unfortunate you're having this issue. Just to let you know, though, I have updated my answer in response to your comments. But here is the quicky version... Jun 19, 2020 at 8:56
  • 1
    @Chad "Is there an interactive shell separate from my computer that still lets it affect my computer?" - I can't think of any offhand, but that doesn't mean they aren't out there (I'm probably missing something obvious...). That said, FYI, you don't need environment variables set to allow e.g. pip to work correctly. You just have to type longer paths. You can access pip for Python 3.7, for example, with ex. C:\Python37\Scripts\pip.exe example-command. However, the way I would recommend using pip (because it's good habit anyway) is C:\Python37\python.exe -m pip example-command. Jun 19, 2020 at 9:00
0

Clean (uninstall) your system of all Python installations. Use RegEdit if necessary.

Then install the Anaconda Navigator distribution. Make sure you install it (as Windows Administrator) in the directory "C:\ProgramData\Anaconda3" Then use conda to create all your virtual environments. Use 'conda' as your centralized virtual environment manager that comes with Anaconda. It is cleaner and by default stores all environments into the "C:\ProgramData\Anaconda3\envs" directory (if it is configured correctly).

If you still want to use pip / venv, then install conda and pip packages in a conda environment, but follow these instructions: The best guide to pip and conda together is here: using conda and pip together

BE MINDFUL WHEN USING PIP AND CONDA TOGETHER:

Be careful about using pip and conda "side-by-side". They each build and manage their own package indexes. Interoperability is still an "experimental feature". You can try the interoperability feature of conda. conda and pip interoperability

One thing that I usually do is install the conda and pip packages into any new conda environment first (using "conda install -c conda-forge conda pip" at the command line). After that conda then is informed about the pip package installations. I find that pip corrupts my conda environments less frequently when I do this.

See the following document for more information about using pip inside conda environments. conda and pip interoperability

Pip with venv can leave a mess on your system, because it lets you "pip-poop" venv environments all over your file system, like rodent droppings all over an attic. pip will drop a "venv" virtual environment in whatever directory you happen to be in at the time. pip does not have a centralized environment manager, which I hate because I forget where I have them and then my system gets cluttered with storage lost to old venv folders that are not centrally managed. I prefer to let conda automate management by centralizing, tracking, and managing them all in one place. The conda environment and package manager saves me time, increases productivity and uses my computer more effectively.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .