pipenv: Traceback doesn't help with "Invalid file object"

Running pipenv install, seems to install all 54 dependencies, but errors at the end with:

ValueError: Invalid file object: <_io.TextIOWrapper name=85 encoding='UTF-8'>

My project seems to work fine, but the error is unexpected. I infer that the problem is in one of the packages rather than in pipenv, but the traceback below gives no clues to what package is giving rise to the error.

  1. Mac OS 10.13
  2. Python 3.6.3
  3. pipenv, version 8.2.7

Full traceback:

(iris-E1jYNxJE) bash-3.2$ pipenv install
Installing dependencies from Pipfile.lock (a7cc07)…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 54/54 — 00:00:12
Traceback (most recent call last):
  File "/Users/shacker/Library/Python/3.6/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv==8.2.7', 'console_scripts', 'pipenv')()
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/cli.py", line 1809, in install
    do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy)
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/cli.py", line 1301, in do_init
    skip_lock=skip_lock, verbose=verbose, concurrent=concurrent)
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/cli.py", line 830, in do_install_dependencies
    cleanup_procs(procs, concurrent)
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/cli.py", line 718, in cleanup_procs
    c.block()
  File "/Users/shacker/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/delegator.py", line 192, in block
    stdout, stderr = self.subprocess.communicate()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 843, in communicate
    stdout, stderr = self._communicate(input, endtime, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1505, in _communicate
    selector.register(self.stdout, selectors.EVENT_READ)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/selectors.py", line 351, in register
    key = super().register(fileobj, events, data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/selectors.py", line 237, in register
    key = SelectorKey(fileobj, self._fileobj_lookup(fileobj), events, data)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/selectors.py", line 224, in _fileobj_lookup
    return _fileobj_to_fd(fileobj)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/selectors.py", line 39, in _fileobj_to_fd
    "{!r}".format(fileobj)) from None
ValueError: Invalid file object: <_io.TextIOWrapper name=69 encoding='UTF-8'>

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 36 (27 by maintainers)

Most upvoted comments

So I think the technical aspect of this should be fixed in #935, but I’m going to leave this open with a documentation TODO.

We should really have a “intro to pipenv” or “pipenv workflow” section giving a detailed breakdown of these things. I think we have close to a dozen issues now with one of us explaining things, but it’s somehow never made it into the docs.

@shacker That’s probably a good idea re: error reporting – it’s a race condition having to do with multiple threads attempting to lock/open multiple file handles simultaneously when configuring VCS dependencies. This is fixed upstream but not released yet, as in the future we will not use multithreaded installation for VCS dependencies. The reason I can’t reproduce it is probably just that I didn’t attempt it enough times or I’m not on mac or I don’t have the exact right alignment of venus with jupiter in the 3rd house or whatever to cause the exact conditions to have this happen.

As for pipenv telling you how to activate the virtualenv, technically this is correct, pipenv shell does activate the virtualenv. It is just neglecting to mention the fact that you should use pipenv run instead. I doubt you will be the only person to see this and adopt this workflow. Our documentation has fallen behind a bit, we do need to spend some time catching it up.