pipenv --three failed; pipenv --support failed

Created on 25 May 2019  路  7Comments  路  Source: pypa/pipenv

Issue description

pipenv --three failed
pipenv --support failed

Expected result

Pipenv to be initialized with python three

Actual result

C:\repo_git\lbforum-site>pipenv
Usage: pipenv [OPTIONS] COMMAND [ARGS]...

Options:
  --where             Output project home information.
  --venv              Output virtualenv information.
  --py                Output Python interpreter information.
  --envs              Output Environment Variable options.
  --rm                Remove the virtualenv.
  --bare              Minimal output.
  --completion        Output completion (to be eval'd).
  --man               Display manpage.
  --support           Output diagnostic information for use in GitHub issues.
  --site-packages     Enable site-packages for the virtualenv.  [env var:
                      PIPENV_SITE_PACKAGES]
  --python TEXT       Specify which version of Python virtualenv should use.
  --three / --two     Use Python 3/2 when creating virtualenv.
  --clear             Clears caches (pipenv, pip, and pip-tools).  [env var:
                      PIPENV_CLEAR]
  -v, --verbose       Verbose mode.
  --pypi-mirror TEXT  Specify a PyPI mirror.
  --version           Show the version and exit.
  -h, --help          Show this message and exit.


Usage Examples:
   Create a new project using Python 3.7, specifically:
   $ pipenv --python 3.7

   Remove project virtualenv (inferred from current directory):
   $ pipenv --rm

   Install all dependencies for a project (including dev):
   $ pipenv install --dev

   Create a lockfile containing pre-releases:
   $ pipenv lock --pre

   Show a graph of your installed dependencies:
   $ pipenv graph

   Check your installed dependencies for security vulnerabilities:
   $ pipenv check

   Install a local setup.py into your virtual environment/Pipfile:
   $ pipenv install -e .

   Use a lower-level pip command:
   $ pipenv run pip freeze

Commands:
  check      Checks for security vulnerabilities and against PEP 508 markers
             provided in Pipfile.
  clean      Uninstalls all packages not specified in Pipfile.lock.
  graph      Displays currently-installed dependency graph information.
  install    Installs provided packages and adds them to Pipfile, or (if no
             packages are given), installs all packages from Pipfile.
  lock       Generates Pipfile.lock.
  open       View a given module in your editor.
  run        Spawns a command installed into the virtualenv.
  shell      Spawns a shell within the virtualenv.
  sync       Installs all packages specified in Pipfile.lock.
  uninstall  Un-installs a provided package and removes it from Pipfile.
  update     Runs lock, then sync.

C:\repo_git\lbforum-site>pipenv --three
Traceback (most recent call last):
  File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37\Scripts\pipenv.exe\__main__.py", line 9, in <module>
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\cli\command.py", line 208, in cli
    clear=state.clear,
  File "c:\python37\lib\site-packages\pipenv\core.py", line 574, in ensure_project
    pypi_mirror=pypi_mirror,
  File "c:\python37\lib\site-packages\pipenv\core.py", line 494, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "c:\python37\lib\site-packages\pipenv\core.py", line 397, in ensure_python
    path_to_python = find_a_system_python(python)
  File "c:\python37\lib\site-packages\pipenv\core.py", line 360, in find_a_system_python
    python_entry = finder.find_python_version(line)
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 108, in find_python_version
    match = self.windows_finder.find_python_version(
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 63, in windows_finder
    self._windows_finder = WindowsFinder()
  File "<attrs generated init f6f3fa3ede65103f785fe13d9eaf01870dbc2ce1>", line 13, in __init__
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 92, in get_versions
    py_version = PythonVersion.from_windows_launcher(version_object)
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 417, in from_windows_launcher
    creation_dict = cls.parse(launcher_entry.info.version)
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\_vendor\pep514tools\_registry.py", line 75, in __getattr__
    raise AttributeError(attr)
AttributeError: version

Steps to replicate

The file "Pipfile" is generated automatically锛宐ut it is empty.

I have tried to reinstall the pipenv as follows, but it was still the same.

pip uninstall pipenv
pip install pipenv


Please run $ pipenv --support, and paste the results here. Don't put backticks (`) around it! The output already contains Markdown formatting.

C:\repo_git\lbforum-site>pipenv --support | clip
Traceback (most recent call last):
  File "c:\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python37\Scripts\pipenv.exe\__main__.py", line 9, in <module>
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\vendor\click\decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "c:\python37\lib\site-packages\pipenv\cli\command.py", line 146, in cli
    get_pipenv_diagnostics()
  File "c:\python37\lib\site-packages\pipenv\help.py", line 33, in get_pipenv_diagnostics
    python_paths = finder.find_all_python_versions()
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 122, in find_all_python_versions
    python_version_dict = getattr(self.system_path, "python_version_dict")
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\pythonfinder.py", line 54, in system_path
    ignore_unsupported=self.ignore_unsupported,
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 451, in create
    ignore_unsupported=ignore_unsupported,
  File "<attrs generated init 75e45f144e3d5510d54dd5fca6730b98fa0220a9>", line 38, in __init__
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 114, in __attrs_post_init__
    self._setup_windows()
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\path.py", line 213, in _setup_windows
    self.windows_finder = WindowsFinder.create()
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 116, in create
    return cls()
  File "<attrs generated init 50701ee5ba117d87d8b85d488f0b2f29fb395f04>", line 13, in __init__
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\windows.py", line 92, in get_versions
    py_version = PythonVersion.from_windows_launcher(version_object)
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\models\python.py", line 417, in from_windows_launcher
    creation_dict = cls.parse(launcher_entry.info.version)
  File "c:\python37\lib\site-packages\pipenv\vendor\pythonfinder\_vendor\pep514tools\_registry.py", line 75, in __getattr__
    raise AttributeError(attr)
AttributeError: version

C:\repo_git\lbforum-site>
Status

Most helpful comment

@children1987 Thanks for the information clarifying what is happening.

There exist stale keys in your registry. To fix this,

  1. Fully uninstall Python2.7
  2. Check the registry with regedit and manually clear the keys of 2.7 at HKCU/Software/Python/PythonCore(or HKLM/Software/Python/PythonCore depending on how you installed Python.

All 7 comments

It seems like, my python3 is ok, as follows:

C:\repo_git\lbforum-site>python3
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>

And I am sure, pipenv is ok when it was some days ago.

Seems there is a broken python installation on your system.

A bit tricky, but the output of the following would be helpful:

import pipenv
from pythonfinder._vendor.pep514tools.environment import findall
for version in findall():
    print(version.info())

C:\Users\39188\Desktop>python3
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

import pipenv
from pythonfinder._vendor.pep514tools.environment import findall
for version in findall():
... print(version.info())
...
Traceback (most recent call last):
File "", line 2, in
TypeError: 'PythonWrappedDict' object is not callable
type(version.info)

print(version.info)
info(install_path=info(='C:\Python27'), python_path=info(='C:\Python27;C:\Python27\Lib\;C:\Python27\DLLs\'))

I am so puzzled. Why it calls python27?! I thought it should call python37 in 'C:\Python37'.

@children1987 sorry for the mistake in my last comment and I am glad you figured out.

for version in findall():
    print(version.info)

Can you iterate all results of findall() and print them out?

C:\Users\39188>python3
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pipenv
>>> from pythonfinder._vendor.pep514tools.environment import findall
>>> for version in findall():
...     print(version.info)
...
info(install_path=info(='C:\\Python27'), python_path=info(='C:\\Python27;C:\\Python27\\Lib\\;C:\\Python27\\DLLs\\'))
info(help=info(Pythonwin Reference=info(='C:\\Python27\\Lib\\site-packages\\PyWin32.chm')), modules=info(), display_name='Python 2.7', support_url='http://www.python.org/', version='2.7', sys_version='2.7', sys_architecture='64bit')
info(help=info(Main Python Documentation=info(='C:\\Python37\\Doc\\python373.chm')), idle=info(='C:\\Python37\\Lib\\idlelib\\idle.pyw'), idle_shortcuts=info(), installed_features=info(dev='3.7.3150.0', shortcuts='3.7.3150.0', exe='3.7.3150.0', lib='3.7.3150.0', test='3.7.3150.0', doc_shortcut='3.7.3150.0', doc='3.7.3150.0', tools='3.7.3150.0', tcltk='3.7.3150.0', pip='3.7.3150.0', path='3.7.3150.0'), install_path=info(='C:\\Python37\\', executable_path='C:\\Python37\\python.exe', windowed_executable_path='C:\\Python37\\pythonw.exe'), python_path=info(='C:\\Python37\\Lib\\;C:\\Python37\\DLLs\\'), display_name='Python 3.7 (64-bit)', support_url='http://www.python.org/', version='3.7.3', sys_version='3.7', sys_architecture='64bit')
>>>

@frostming Thank you so much!

@children1987 Thanks for the information clarifying what is happening.

There exist stale keys in your registry. To fix this,

  1. Fully uninstall Python2.7
  2. Check the registry with regedit and manually clear the keys of 2.7 at HKCU/Software/Python/PythonCore(or HKLM/Software/Python/PythonCore depending on how you installed Python.

@frostming Thank you so much! I did as your list, everything is OK now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AkiraSama picture AkiraSama  路  3Comments

leileigong picture leileigong  路  3Comments

jakul picture jakul  路  3Comments

bgjelstrup picture bgjelstrup  路  3Comments

randName picture randName  路  3Comments