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.

NameError: global name 'NoSectionError' is not defined under Python 2.7

See original GitHub issue

I get this exception being raised when I call pip-upgrade with Python2.7. The problem is in pip_upgrader/packages_status_detector.py", line 80:

try:
    from configparser import ConfigParser, NoOptionError, NoSectionError
except ImportError:   # pragma: nocover
    from ConfigParser import ConfigParser, NoOptionError

[…]

except (NoOptionError, NoSectionError):  # pragma: nocover

If you have ConfigParser then the NoSectionError exception is not imported thus the above error.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
simioncommented, Nov 23, 2017

Cool, no problem 😄

1reaction
kieruncommented, Nov 23, 2017

Changing

from ConfigParser import ConfigParser, NoOptionError

to

from ConfigParser import ConfigParser, NoOptionError, NoSectionError

fixed it for me.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 2.7 Global name not defined - Stack Overflow
Indeed you never defined name R . Fix that by replacing: for j in range(n2): R[j] = numbers[m+j+1]. with: R = [numbers[m+j+1] for...
Read more >
How to Setup Your Python Environment for Machine Learning ...
In this tutorial, you will discover how to set up a Python ... Keras: when I try to print it says “NameError: name...
Read more >
ConfigParser – Work with configuration files - PyMOTW
It consists of one or more named sections, each of which can contain individual options with names and values. Config file sections are...
Read more >
class 'ConfigParser.NoSectionError'
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they...
Read more >
Index — Python 3.11.1 documentation
python --m-py_compile command line option. - (minus). binary operator, [1] · in ... --no-type-comments ... --with-framework-name. command line option.
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