Search code examples
pythonwindowssystem-error

Python36.dll is missing


This is technically a duplicate of this question and this other question, but there are no answers to any of these. I've also been googling this problem and could almost find no information, thus I ask here.

Issue

When I run python in a Command Prompt (windows) I get the following error

The code execution cannot proceed because python36.dll was not found. Reinstalling the program may fix this problem.

Some Background

(I think) the problem began after installing python 3.8 via this website which had a direct download link to an installer. It is of course not the best idea to install python from any external source, and since the problems began here, I decided to check if this was a virus. I ran Avast and nothing was found. I also downloaded the same version of python from the official website and used a file compare tool to check if anything had been changed in the installer, and it found nothing. I can thus confirm a virus did not cause this.

I've tried to...

  • Reinstall python - Did not fix the problem
  • Restart my pc - Did not fix the problem

My question is...

How would one go about solving this issue?

(Also, if there indeed is an answer to this question which I have missed, I apologize. I'm kinda new on stackoverflow!)


Solution

  • Your $PATH variable is most likely not set properly. Most likely, some other app modified your $PATH variable on your system to direct python towards a folder that doesn't contain a Python installation. Check out this article for some information on how to check your PATH and modify it. (disclosure: I randomly googled and picked this article out of the top 5 results because it looks like it gives the clearest explanation.)

    Also, try using PowerShell and not cmd.exe, PowerShell behaves as expected with $PATH changes, cmd.exe sometimes doesn't work.

    A potentially overkill solution: Use the Windows Application manager in Settings to uninstall any existing Python installations, get a fresh copy of the installer from the official Python website (be sure you get the installer for the right version, if you need a specific version), and run the installation again, fresh. Double check the installation prompts to be sure it adds Python to your $PATH, and then use PowerShell to run Python. That specific .dll is for Python 3.6, so start by trying to install that version first.