I used conda for the virtual environment, but now I'm going to use pipenv I was addicted to erasing Anaconda and trying to migrate.
Target error message
ValueError: Not a valid python path: 'C:/Users/<username>/Anaconda3/python.exe'
Because the Anaconda registry key wasn't completely erased
pipenv
was trying to reference and returned ValueError
.
I will list three solutions in order of cleanliness.
From https://github.com/pypa/pipenv/issues/4334 Delete the registry key so that it does not refer to Anaconda.
Computer \ HKEY_CURRENT_USER \ Software \ Python \ Continuum Analytics \ Anaconda37-64
From https://github.com/pypa/pipenv/issues/4334
cmd
pip install pipenv==2018.10.13
Replace with the old version.
Modify C: \ Users \ <username> \ AppData \ Local \ Programs \ Python \ Python37 \ Lib \ site-packages \ pipenv \ vendor \ pythonfinder \ models \ windows.py
.
windows.py(Line 113)
- versions[py_version.version_tuple[:5]] = base_dir
+ try:
+ versions[py_version.version_tuple[:5]] = base_dir
+ except ValueError as e:
+ print(e)
+ continue
Searching for an error message to find a solution ...
--Uninstall Anaconda (conda clean-> Delete Anaconda directory)
--Reinstall Python 3.7.9
--Delete C: \ Users
C: \ Users \ <username> \ AppData \ Local \ Programs \ Python \ Python37 \ Lib \ site-packages \ pipenv
I looked inside and put a print statement in a place that seemed to be related and followed the process.
→ Is it the fastest to follow the error message from the bottom and handle the error at the error location?
TODO
--Deepen your understanding of registry keys
--Write sample code using Python's built-in module winreg
to deepen your understanding
--Read code and deepen your understanding of how pipenv \ vendor \ pythonfinder
works
Microsoft Windows [Version 10.0.18363.1198]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\<username>>pipenv --python 3.7
Traceback (most recent call last):
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 618, in parse_executable
result_version = get_python_version(path)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\pythonfinder\utils.py", line 105, in get_python_version
c = subprocess.Popen(version_cmd, **subprocess_kwargs)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2]The specified file could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\<username>\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\<username>\AppData\Local\Programs\Python\Python37\Scripts\pipenv.exe\__main__.py", line 7, in <module>
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
rv = self.invoke(ctx)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1236, in invoke
return Command.invoke(self, ctx)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
return callback(*args, **kwargs)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\cli\command.py", line 205, in cli
clear=state.clear,
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\core.py", line 580, in ensure_project
pypi_mirror=pypi_mirror,
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\core.py", line 498, in ensure_virtualenv
python = ensure_python(three=three, python=python)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\core.py", line 388, in ensure_python
path_to_python = find_a_system_python(python)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\core.py", line 354, in find_a_system_python
python_entry = find_python(finder, line)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\utils.py", line 2213, in find_python
result = finder.find_python_version(line)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 276, in find_python_version
if os.name == "nt" and self.windows_finder is not None:
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 129, in windows_finder
self._windows_finder = WindowsFinder()
File "<attrs generated init pipenv.vendor.pythonfinder.models.windows.WindowsFinder>", line 13, in __init__
File "c:\users\<username>\appdata\local\programs\python\python37\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\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 365, in __getattribute__
result = super(PythonVersion, self).__getattribute__(key)
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 430, in version_tuple
self.patch,
File "c:\users\<username>\appdata\local\programs\python\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 375, in __getattribute__
instance_dict = self.parse_executable(executable)
File "c:\users\<username>\appdata\local\programs\python\python37\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:/Users/<username>/Anaconda3/python.exe'
Recommended Posts