New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I/O operation on closed file exception with --log #219

Closed
vbabiy opened this Issue Mar 15, 2011 · 6 comments

Comments

Projects
None yet
7 participants
@vbabiy
Contributor

vbabiy commented Mar 15, 2011

When using the --log option, a "ValueError: I/O operation on closed file exception" is raised when an error occurs.

$ pip install abcxyz --log=test.log
Downloading/unpacking abcxyz
  Could not fetch URL http://pypi.python.org/simple/abcxyz: HTTP Error 404: Not Found (abcxyz does not have any releases)
  Will skip URL http://pypi.python.org/simple/abcxyz when looking for download links for abcxyz
  Could not find any downloads that satisfy the requirement abcxyz
No distributions at all found for abcxyz
Storing complete log in ./pip-log.txt
Traceback (most recent call last):
  File "/usr/bin/pip", line 3, in <module>
    pip.main()
  File "/usr/lib/python2.6/dist-packages/pip.py", line 893, in main
    return command.main(initial_args, args[1:], options)
  File "/usr/lib/python2.6/dist-packages/pip.py", line 266, in main
    logger.fatal('Storing complete log in %s' % log_fn)
  File "/usr/lib/python2.6/dist-packages/pip.py", line 3353, in fatal
    self.log(self.FATAL, msg, *args, **kw)
  File "/usr/lib/python2.6/dist-packages/pip.py", line 3378, in log
    consumer.write(rendered+'\n')
ValueError: I/O operation on closed file

@pnasrat

This comment has been minimized.

Show comment
Hide comment
@pnasrat

pnasrat May 1, 2011

Contributor

Still occurs on develop, we explicitly close log_fd before the exit block, removing the log statement there prevents the traceback, which I may propose for now and then look at improving logging in general later (eg there are no timestamps, etc).

Contributor

pnasrat commented May 1, 2011

Still occurs on develop, we explicitly close log_fd before the exit block, removing the log statement there prevents the traceback, which I may propose for now and then look at improving logging in general later (eg there are no timestamps, etc).

@pnasrat

This comment has been minimized.

Show comment
Hide comment
@pnasrat

pnasrat May 6, 2011

Contributor

Possibly the fix proposed in Issue #114 would fix this.

Contributor

pnasrat commented May 6, 2011

Possibly the fix proposed in Issue #114 would fix this.

@thurloat

This comment has been minimized.

Show comment
Hide comment
@thurloat

thurloat Apr 15, 2013

Was having the same issue today while pip installing on a RHEL machine where the user didn't have a writable home directory. Even while passing --log and --log-file arguments, it still tried to write out to the ~/.pip/log file.

Note that this failure only occurred while installing requirements which compiled c-extensions. The --log argument did capture the regular pip log.

Was having the same issue today while pip installing on a RHEL machine where the user didn't have a writable home directory. Even while passing --log and --log-file arguments, it still tried to write out to the ~/.pip/log file.

Note that this failure only occurred while installing requirements which compiled c-extensions. The --log argument did capture the regular pip log.

@ghost ghost assigned hltbra Apr 19, 2013

@andresriancho

This comment has been minimized.

Show comment
Hide comment
@andresriancho

andresriancho Jul 10, 2013

I'm also seeing this error in my installs and it's really annoying!

@hltbra did you send a pull request to the pip project for this?

I'm also seeing this error in my installs and it's really annoying!

@hltbra did you send a pull request to the pip project for this?

@trishankkarthik

This comment has been minimized.

Show comment
Hide comment
@trishankkarthik

trishankkarthik Aug 16, 2013

I can confirm that this is still happening with pip 1.4.1. We see it frequently while testing pip over TUF.

Without logging:

$ pip install RandomNonExtantPackage
Downloading/unpacking RandomNonExtantPackage
  Could not find any downloads that satisfy the requirement RandomNonExtantPackage
Cleaning up...
No distributions at all found for RandomNonExtantPackage
Storing complete log in /home/trishank/.pip/pip.log

With logging:

$ pip install RandomNonExtantPackage --log iamalog.txt
Downloading/unpacking RandomNonExtantPackage
  Could not find any downloads that satisfy the requirement RandomNonExtantPackage
Cleaning up...
No distributions at all found for RandomNonExtantPackage
Storing complete log in /home/trishank/.pip/pip.log
Traceback (most recent call last):
  File "/home/trishank/stress-test.updateframework.com/test/bin/pip", line 9, in <module>
    load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/__init__.py", line 148, in main
    return command.main(args[1:], options)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/basecommand.py", line 176, in main
    logger.fatal('Storing complete log in %s' % log_fn)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/log.py", line 48, in fatal
    self.log(self.FATAL, msg, *args, **kw)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/log.py", line 75, in log
    backwardcompat.fwrite(consumer, rendered)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/backwardcompat/__init__.py", line 90, in fwrite
    f.write(s)
ValueError: I/O operation on closed file

I can confirm that this is still happening with pip 1.4.1. We see it frequently while testing pip over TUF.

Without logging:

$ pip install RandomNonExtantPackage
Downloading/unpacking RandomNonExtantPackage
  Could not find any downloads that satisfy the requirement RandomNonExtantPackage
Cleaning up...
No distributions at all found for RandomNonExtantPackage
Storing complete log in /home/trishank/.pip/pip.log

With logging:

$ pip install RandomNonExtantPackage --log iamalog.txt
Downloading/unpacking RandomNonExtantPackage
  Could not find any downloads that satisfy the requirement RandomNonExtantPackage
Cleaning up...
No distributions at all found for RandomNonExtantPackage
Storing complete log in /home/trishank/.pip/pip.log
Traceback (most recent call last):
  File "/home/trishank/stress-test.updateframework.com/test/bin/pip", line 9, in <module>
    load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/__init__.py", line 148, in main
    return command.main(args[1:], options)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/basecommand.py", line 176, in main
    logger.fatal('Storing complete log in %s' % log_fn)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/log.py", line 48, in fatal
    self.log(self.FATAL, msg, *args, **kw)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/log.py", line 75, in log
    backwardcompat.fwrite(consumer, rendered)
  File "/home/trishank/stress-test.updateframework.com/test/local/lib/python2.7/site-packages/pip/backwardcompat/__init__.py", line 90, in fwrite
    f.write(s)
ValueError: I/O operation on closed file
@qwcode

This comment has been minimized.

Show comment
Hide comment
@qwcode

qwcode Sep 20, 2013

Contributor

fixed in PR #1205

Contributor

qwcode commented Sep 20, 2013

fixed in PR #1205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment