When creating a pipenv environment, I got addicted to "Value Error: Not a valid python path"

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'

Cause

Because the Anaconda registry key wasn't completely erased pipenv was trying to reference and returned ValueError.

Prerequisites

Solution

I will list three solutions in order of cleanliness.

Part 1

From https://github.com/pypa/pipenv/issues/4334 Delete the registry key so that it does not refer to Anaconda.

  1. Enter "regedit" in "Win + R".
  2. Delete the directory Computer \ HKEY_CURRENT_USER \ Software \ Python \ Continuum Analytics \ Anaconda37-64
    from the right click.

Part 2

From https://github.com/pypa/pipenv/issues/4334

cmd


pip install pipenv==2018.10.13

Replace with the old version.

Part 3

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

What I tried before I got to the solution

Searching for an error message to find a solution ...

--Uninstall Anaconda (conda clean-> Delete Anaconda directory) --Reinstall Python 3.7.9 --Delete C: \ Users .virtualenvs --Reinstall pipenv --Restart your PC

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

Full error message

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

When creating a pipenv environment, I got addicted to "Value Error: Not a valid python path"
I was addicted to creating a Python venv environment with VS Code
What I was addicted to when creating a web application in a windows environment
I got stuck when trying to specify a relative path with relative_to () in python
I got a Value Error when using JUMAN ++ with PyKNP
A note I was addicted to when creating a table with SQLAlchemy
"Value Error: Unable to configure handler'file_output_handler'" when starting a python program
I want to build a Python environment
Things to watch out for when creating a Python environment on a Mac
A story I was addicted to when inserting from Python to a PostgreSQL table
Python Note: When assigning a value to a string
A memo when creating a python environment with miniconda
A note I was addicted to when running Python with Visual Studio Code
A story that I was addicted to when I made SFTP communication with python
When I tried to introduce python3 to atom, I got stuck
What I was addicted to when using Python tornado
When I tried to install PIL and matplotlib in a virtualenv environment, I was addicted to it.
What I was addicted to when dealing with huge files in a Linux 32bit environment
What I was addicted to when migrating Processing users to Python
When I got a list of study sessions in Python, I found something I wanted to make
When I tried to scrape using requests in python, I was addicted to SSLError, so a workaround memo
I wrote AWS Lambda, and I was a little addicted to the default value of Python arguments
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
I tried to convert a Python file to EXE (Recursion error supported)
I got a TypeError:'int' object is not iterable when using keras
What I was addicted to when introducing ALE to Vim for Python
A note I was addicted to when making a beep on Linux
Error when building mac python environment
Precautions when creating a Python generator
[Python] When I tried to make a decompression tool with a zip file I just knew, I was addicted to sys.exit ()
I get an error when I put a Python plugin in Visual Studio Code under the pyenv environment
I get a UnicodeDecodeError when trying to connect to oracle with python sqlalchemy
A reminder of what I got stuck when starting Atcoder with python
[Python] I was addicted to not saving internal variables of lambda expressions
I tried to build a Mac Python development environment with pythonz + direnv
What to do when psycopg2 throws an error when pipenv lock under Pipenv environment
Note when creating an environment with python
Creating a python virtual environment on Windows
What I was addicted to Python autorun
Add a Python virtual environment to VSCode
[Python] I want to know the variables in the function when an error occurs!
I want to create a nice Python development environment for my new Mac
I want to use Python in the environment of pyenv + pipenv on Windows 10
I got an error when trying to run Hello World in Go language
Three things I was addicted to when using Python and MySQL with Docker
Output timing is incorrect when standard (error) output is converted to a file in Python
When I tried to connect with SSH, I got a warning about free space.
[Python] What to check when you get a Unicode Decode Error in Django
Linux Ubuntu16.04 I got a little scary error when I ran a command using sudo
Error when installing a module with Python pip
When I get a chromedriver error in Selenium
Ubuntu18.04.05 Creating a python virtual environment in LTS
I want to create a window in Python
I want to make a game with Python
How to add a Python module search path
Commands for creating a python3 environment with virtualenv
Procedure for creating a Python quarantine environment (venv environment)
What I did when updating from Python 2.6 to 2.7
A memo for creating a python environment by a beginner
Error when trying to install psycopg2 in Python
I want to write to a file with Python