pipenv: ValueError: Not a valid python path: 'C:/Program Files/Python351/python.exe'

Here is the output of pipenv --support | clip: The path which is causing the error may have existed on my Windows 10 PC, but thefolder C:/Program Files/Python351 no longer exists on my PC. I do not understand where pipenv finds a reference to this non-existing folder and I do not know how to solve this problem.

I have been successfully using the following command to create a virtual env for several new django projects: pipenv install django>=3.0 but now running this command gives this valueerror.

I will very much appreciate a solution to my problem.

G:\Documenten\python_projects\django_for_beginners_projects\newspaper_pycharmproject

λ pipenv --support | clip
Traceback (most recent call last):
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 618, in parse_executable
    result_version = get_python_version(path)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\utils.py", line 105, in get_python_version
    c = subprocess.Popen(version_cmd, **subprocess_kwargs)
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Het systeem kan het opgegeven bestand niet vinden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Scripts\pipenv.exe\__main__.py", line 7, in <module>
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\click\core.py", line 1236, in invoke
    return Command.invoke(self, ctx)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\cli\command.py", line 139, in cli
    get_pipenv_diagnostics()
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\help.py", line 33, in get_pipenv_diagnostics
    python_paths = finder.find_all_python_versions()
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 312, in find_all_python_versions
    python_version_dict = getattr(self.system_path, "python_version_dict", {})
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 120, in system_path
    self._system_path = self.create_system_path()
  File "c:\users\martin\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 82, in create_system_path
    return pyfinder_path.SystemPath.create(
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 682, in create
    instance = instance._run_setup()
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 233, in _run_setup
    new_instance = new_instance._setup_windows()
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 411, in _setup_windows
    windows_finder = WindowsFinder.create()
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 146, in create
    return cls()
  File "<attrs generated init pythonfinder.models.windows.WindowsFinder>", line 13, in __init__
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 113, in get_versions
    versions[py_version.version_tuple[:5]] = base_dir
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 365, in __getattribute__
    result = super(PythonVersion, self).__getattribute__(key)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 430, in version_tuple
    self.patch,
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 375, in __getattribute__
    instance_dict = self.parse_executable(executable)
  File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 620, in parse_executable
    raise ValueError("Not a valid python path: %r" % path)
ValueError: Not a valid python path: 'C:/Program Files/Python351/python.exe'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 22 (2 by maintainers)

Most upvoted comments

Anyone facing a similar error needs to uninstall old python versions C:\Windows\regedit.exe HKLM\SOFTWARE\Python\PythonCore
HKCU\SOFTWARE\Python\PythonCore\

My advice to you: look for Python351 in regedit (win+r , regedit) and delete the entries (their content)

Someone suggested to use an older version in another thread.

pip install pipenv==2018.10.13

It fixed the issue for me, before I was also stuck on the Anaconda path

To add to @snooppr, I had to look in

HKLM\SOFTWARE\WOW6432Node\Python\PythonCore\
HKCU\SOFTWARE\WOW6432Node\Python\PythonCore\

as well.

I was having a similar issue with pipenv and getting the same error messages. Searching regedit did pull up some random entries to an uninstalled version of Python which I deleted. I stopped getting the error messages when I went back and installed the version of Python that was being mentioned (in martin’s case that would be 3.5.1) in the same location that pipenv was trying to find the directory. Then, I uninstalled it using the installation exe and it cleared up my issues with pipenv. I hope that helps!