question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

2018.11.26: pipenv emits pythons errors when creating a virtualenv

See original GitHub issue

Issue description

Possibly related to #3229, pipenv continues to throw errors when creating a virtualenv:

$ pipenv --three
['Traceback (most recent call last):\n', '  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/misc.py", line 160, in _create_subprocess\n    combine_stderr=combine_stderr)\n', '  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/misc.py", line 134, in _spawn_subprocess\n    return subprocess.Popen(cmd, **options)\n', '  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__\n    restore_signals, start_new_session)\n', '  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child\n    raise child_exception_type(errno_num, err_msg, err_filename)\n', "FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/pythonz': '/usr/local/bin/pythonz'\n", '\nDuring handling of the above exception, another exception occurred:\n\n', 'Traceback (most recent call last):\n', '  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/contextmanagers.py", line 150, in spinner\n    yield _spinner\n', '  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/misc.py", line 314, in run\n    write_to_stdout=True\n', '  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/misc.py", line 162, in _create_subprocess\n    sys.stderr.write("Error %s while executing command %s", exc, " ".join(cmd._parts))\n', 'TypeError: write() takes exactly one argument (3 given)\n']
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/misc.py", line 160, in _create_subprocess
    combine_stderr=combine_stderr)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/misc.py", line 134, in _spawn_subprocess
    return subprocess.Popen(cmd, **options)
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python/3.6.5_1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/pythonz': '/usr/local/bin/pythonz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli/command.py", line 208, in cli
    clear=state.clear,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 574, in ensure_project
    pypi_mirror=pypi_mirror,
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 516, in ensure_virtualenv
    ensure_python(three=three, python=python)
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 397, in ensure_python
    path_to_python = find_a_system_python(python)
  File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 360, in find_a_system_python
    python_entry = finder.find_python_version(line)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 114, in find_python_version
    major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch, name=name
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 396, in find_python_version
    ver = next(iter(self.get_pythons(sub_finder)), None)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 279, in get_pythons
    reverse=True
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 277, in <genexpr>
    (p for p in self._filter_paths(finder) if p.is_python),
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 264, in <genexpr>
    pth for pth in unnest(finder(p) for p in self.path_entries if p is not None)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/utils.py", line 251, in unnest
    for el in target:
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 264, in <genexpr>
    pth for pth in unnest(finder(p) for p in self.path_entries if p is not None)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/mixins.py", line 121, in find_python_version
    for child in unnest(self.pythons.values())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 531, in pythons
    for path, entry in self.children.items():
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 501, in children
    for child_key, child_val in self._gen_children():
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 493, in _gen_children
    entry = PathEntry.create(path=child, **pass_args)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 575, in create
    _new = cls(**creation_args)
  File "<attrs generated init b90d7581ea07925e94241736776cf96c889eb52c>", line 16, in __init__
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 518, in get_py_version
    py_version = PythonVersion.from_path(path=self, name=self.name)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/models/python.py", line 395, in from_path
    py_version = get_python_version(path.path.absolute().as_posix())
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pythonfinder/utils.py", line 68, in get_python_version
    combine_stderr=False, write_to_stdout=False)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/misc.py", line 314, in run
    write_to_stdout=True
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/vistir/misc.py", line 162, in _create_subprocess
    sys.stderr.write("Error %s while executing command %s", exc, " ".join(cmd._parts))
TypeError: write() takes exactly one argument (3 given)

Expected result

Expected no error logging while simply creating a virtualenv.

Actual result

virtualenv creation fails.

Steps to replicate

$ pipenv --three

pipenv --support also emits these errors and fails to collect support information!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:30 (5 by maintainers)

github_iconTop GitHub Comments

89reactions
command-tabcommented, Jan 8, 2019

The current release sure seems hosed to me. Another temporary workaround I saw in a past issue was to specifically pass in a python path like so:

pipenv --three --python=`which python3`

I’ve been doing this with success for the time being 😬

10reactions
pavithrarajscommented, Aug 4, 2019

Ah ok. And yeah the bug makes sense. I’ll just tag it upstream and make sure it gets fixed

Still issue persists, any idea when this fix will be released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error when creating a pipenv virtual environment with python 3.7
I'm trying to create a virtual environment with pipenv and python 3.7. The following error occurs when I run pipenv install --python 3.7...
Read more >
pipenv Documentation - Read the Docs
Pipenv is a tool that aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, yarn, etc.) to the. Python...
Read more >
Release and Version History — pipenv 2020.6.2.dev0 ...
Fixed a bug which caused periodic failures in python discovery when executables named python were not present on the target $PATH .
Read more >
pipenv Changelog - pyup.io
- Pipenv will now correctly unqoute special characters in wheel URIs. - Fixed a bug with parsing and grouping old-style setup.py extras during...
Read more >
How to properly install Pipenv on WSL Ubuntu 18.04?
$pipenv check --python=`which python3.7`. Found this answer at 2018.11.26: pipenv emits pythons errors when creating a virtualenv #3363.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found