Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValueError when trying to use pipenv install

I am totally new to this. So I installed pipenv using 'pip install pipenv'. I have python version 3.8.2, pip version 20.1.1 and pipenv version 2020.6.2 . But when I try to run 'pipenv install' it gives the following error.

    C:\Users\rd463>pipenv install
Traceback (most recent call last):
  File "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 618, in parse_executable
    result_version = get_python_version(path)
  File "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\utils.py", line 105, in get_python_version
    c = subprocess.Popen(version_cmd, **subprocess_kwargs)
  File "d:\python382\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "d:\python382\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\python382\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:\python382\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\python382\Scripts\pipenv.exe\__main__.py", line 7, in <module>
  File "D:\python382\Lib\site-packages\pipenv\vendor\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "D:\python382\Lib\site-packages\pipenv\vendor\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "D:\python382\Lib\site-packages\pipenv\vendor\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:\python382\Lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\python382\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\python382\Lib\site-packages\pipenv\vendor\click\decorators.py", line 73, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "D:\python382\Lib\site-packages\pipenv\vendor\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\python382\Lib\site-packages\pipenv\vendor\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "d:\python382\lib\site-packages\pipenv\cli\command.py", line 232, in install
    retcode = do_install(
  File "d:\python382\lib\site-packages\pipenv\core.py", line 1921, in do_install
    ensure_project(
  File "d:\python382\lib\site-packages\pipenv\core.py", line 576, in ensure_project
    ensure_virtualenv(
  File "d:\python382\lib\site-packages\pipenv\core.py", line 498, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "d:\python382\lib\site-packages\pipenv\core.py", line 388, in ensure_python
    path_to_python = find_a_system_python(python)
  File "d:\python382\lib\site-packages\pipenv\core.py", line 350, in find_a_system_python
    return next(iter(finder.find_all_python_versions()), None)
  File "d:\python382\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 "d:\python382\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 120, in system_path
    self._system_path = self.create_system_path()
  File "d:\python382\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 82, in create_system_path
    return pyfinder_path.SystemPath.create(
  File "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 682, in create
    instance = instance._run_setup()
  File "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 233, in _run_setup
    new_instance = new_instance._setup_windows()
  File "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 411, in _setup_windows
    windows_finder = WindowsFinder.create()
  File "D:\python382\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 "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 113, in get_versions
    versions[py_version.version_tuple[:5]] = base_dir
  File "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 365, in __getattribute__
    result = super(PythonVersion, self).__getattribute__(key)
  File "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 430, in version_tuple
    self.patch,
  File "D:\python382\Lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 375, in __getattribute__
    instance_dict = self.parse_executable(executable)
  File "D:\python382\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: 'D:/program_files/Anaconda3/Scripts/python.exe'

Running 'python -m pipenv.help' gives -

C:\Users\rd463>python -m pipenv.help

$ pipenv --support

Pipenv version: '2020.6.2'

Pipenv location: 'D:\\python382\\lib\\site-packages\\pipenv'

Python location: 'D:\\python382\\python.exe'

Python installations found:

followed by the same error again.

I have python installed in 'D:/python382' There is no such directory that the error mentions. I have checked my environment variables and everything is fine there too. Please help me with this error.

Thank you for your time.

like image 923
Devraj Roy Avatar asked Jun 13 '20 15:06

Devraj Roy


People also ask

How do I install a Pipenv file?

Set up a new project with PipenvOpen a console in your project directory and type pipenv install <package_name> to install a package for the project. To specify that the package is for development, use the -d flag. You can use pip syntax to denote a specific version of a package (e.g., black==13.0b1 ).

Is Pipenv installed with Python?

If you installed Python from source, with an installer from python.org, via Homebrew or via Linuxbrew you should already have pip. If you're on Linux and installed using your OS package manager, you may have to install pip separately.

What is the difference between pip install and Pipenv install?

While pip can install Python packages, Pipenv is recommended as it's a higher-level tool that simplifies dependency management for common use cases. This does a user installation to prevent breaking any system-wide packages.


2 Answers

I think the newer version of pipenv is causing the error, I use this command when having the same issue and it worked for me, just use

pip install pipenv==2018.10.13
like image 131
Josehope Avatar answered Sep 19 '22 13:09

Josehope


I had the same problem when I uninstalled Anaconda. Mine got solved after I did the following steps

  1. run regedit.exe

  2. Go to

Computer\HKEY_CURRENT_USER\Software\Python\PythonCore

  1. If there is/are folders having previous versions of python.Delete every version of python other than your current one(for eg.3.7, 3.8 etc. I also had to delete some folder containing something related to anaconda to solve the problem (other than the previous versions)
like image 31
Damodarji Avatar answered Sep 17 '22 13:09

Damodarji