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.

Traceback doesn't help with "Invalid file object"

See original GitHub issue

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'>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:36 (27 by maintainers)

github_iconTop GitHub Comments

1reaction
nateprewittcommented, Oct 22, 2017

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.

1reaction
techalchemycommented, Oct 22, 2017

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - 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.
Read more >
I get a traceback error when I try to open and read through the ...
I get a traceback error when I try to open and read through the objects in a file in a directory. What am...
Read more >
Understanding the Python Traceback
In Python, the term used is traceback. When your program results in an exception, Python will print the current traceback to help you...
Read more >
When Things Go Wrong — PyInstaller 5.7.0 documentation
Analysis also puts messages in a warnings file named build/name/warn-name.txt in the work-path= directory. Analysis creates a message when it detects an import ......
Read more >
Error handling with Python—ArcGIS Pro | Documentation
If a script does not have an error-handling routine, it fails immediately, ... messages for use in Python print(msgs) except: # Get the...
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