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: name 'WindowsError' is not defined

See original GitHub issue

I updated pipenv to version 2018.10.9 using brew, and I am getting the following error when I try to run a command:

Error %s while executing command %s name 'WindowsError' is not defined /usr/local/bin/pythonz -c import sys; print(sys.version.split()[0])
Traceback (most recent call last):
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/vistir/misc.py", line 103, in _spawn_subprocess
    return subprocess.Popen(cmd, **options)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1499, 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/Cellar/pipenv/2018.10.9/libexec/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv==2018.10.9', 'console_scripts', 'pipenv')()
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 1114, in invoke
    return Command.invoke(self, ctx)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/cli/command.py", line 203, in cli
    clear=state.clear,
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/core.py", line 561, in ensure_project
    pypi_mirror=pypi_mirror,
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/core.py", line 484, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/core.py", line 397, in ensure_python
    path_to_python = find_a_system_python(python)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/core.py", line 360, in find_a_system_python
    python_entry = finder.find_python_version(line)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 87, in find_python_version
    major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 261, in find_python_version
    (c for c in sorted(path_filter, key=version_sort, reverse=True)), None
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 258, in <genexpr>
    path_filter = filter(None, (sub_finder(p) for p in paths if p is not None))
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/mixins.py", line 106, in find_python_version
    py_filter, key=lambda child: child[1].version_sort, reverse=True
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/mixins.py", line 96, in <genexpr>
    if child.as_python
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 360, in as_python
    self.py_version = PythonVersion.from_path(self.path)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/models/python.py", line 152, in from_path
    py_version = get_python_version(str(path.path))
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/pythonfinder/utils.py", line 32, in get_python_version
    out, _ = vistir.misc.run(version_cmd, block=True, nospin=True)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/vistir/misc.py", line 236, in run
    spinner=sp,
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/vistir/misc.py", line 122, in _create_subprocess
    c = _spawn_subprocess(cmd, env=env, block=block, cwd=cwd)
  File "/usr/local/Cellar/pipenv/2018.10.9/libexec/lib/python3.7/site-packages/pipenv/vendor/vistir/misc.py", line 104, in _spawn_subprocess
    except WindowsError as e:
NameError: name 'WindowsError' is not defined

I am not sure why I am getting this error. It seems I am getting an OSError related to Windows, but I am on macOS High Sierra 10.13.6. It also seems to be an error related to pythonz.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:7
  • Comments:18 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
simonschmidtcommented, Oct 18, 2018

Same thing on Ubuntu 18.04 with pipenv installed in a venv with:

pip: 18.1 python: 3.6.5 pipenv: 2018.10.13

Found a hacky workaround:

Modify:

…/site-packages/pipenv/vendor/pythonfinder/utils.py

Change the except clause on line 38 to be broader, e.g. except Exception

2reactions
ArtemGordinskycommented, Oct 15, 2018

Still getting this error on 2018.10.13, running MacOS 10.13.6, for some reason. Tried installing both via brew and pip.

$pipenv install
Error %s while executing command %s name 'WindowsError' is not defined /usr/local/bin/pythonz -c import sys; print(sys.version.split()[0])
Traceback (most recent call last):
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/vistir/misc.py", line 103, in _spawn_subprocess
    return subprocess.Popen(cmd, **options)
  File "/usr/local/Cellar/python/3.6.5/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/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 "~/Library/Python/3.6/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/cli/command.py", line 249, in install
    editable_packages=state.installstate.editables,
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/core.py", line 1724, in do_install
    pypi_mirror=pypi_mirror,
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/core.py", line 565, in ensure_project
    pypi_mirror=pypi_mirror,
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/core.py", line 488, in ensure_virtualenv
    python = ensure_python(three=three, python=python)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/core.py", line 401, in ensure_python
    path_to_python = find_a_system_python(python)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/core.py", line 364, in find_a_system_python
    python_entry = finder.find_python_version(line)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/pythonfinder/pythonfinder.py", line 91, in find_python_version
    major=major, minor=minor, patch=patch, pre=pre, dev=dev, arch=arch
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 262, in find_python_version
    (c for c in sorted(path_filter, key=version_sort, reverse=True)), None
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 259, in <genexpr>
    path_filter = filter(None, (sub_finder(p) for p in paths if p is not None))
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/pythonfinder/models/mixins.py", line 106, in find_python_version
    py_filter, key=lambda child: child[1].version_sort, reverse=True
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/pythonfinder/models/mixins.py", line 96, in <genexpr>
    if child.as_python
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/cached_property.py", line 35, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/pythonfinder/models/path.py", line 364, in as_python
    self.py_version = PythonVersion.from_path(self.path)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/pythonfinder/models/python.py", line 162, in from_path
    py_version = get_python_version(str(path.path))
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/pythonfinder/utils.py", line 37, in get_python_version
    out, _ = vistir.misc.run(version_cmd, block=True, nospin=True)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/vistir/misc.py", line 294, in run
    combine_stderr=combine_stderr
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/vistir/misc.py", line 125, in _create_subprocess
    combine_stderr=combine_stderr)
  File "~/Library/Python/3.6/lib/python/site-packages/pipenv/vendor/vistir/misc.py", line 104, in _spawn_subprocess
    except WindowsError as e:
NameError: name 'WindowsError' is not defined
$pipenv --version
pipenv, version 2018.10.13
Read more comments on GitHub >

github_iconTop Results From Across the Web

Where is WindowsError defined? - python - Stack Overflow
According to my Python, it's defined in the built in module named exceptions : ... __module__ 'exceptions' >>> sys.modules[WindowsError.
Read more >
T63231 Undefined global WindowsError in version.py
NameError'>: global name 'WindowsError' is not defined args = ("global name 'WindowsError' is not defined",) message = "global name 'WindowsError' is not ...
Read more >
Issue 5034 in selenium: "global name 'WindowsError' is not ...
Owner: ---- Labels: Type-Defect Priority-Medium Status-Untriaged New issue 5034 by liyaz...@douban.com: "global name 'WindowsError' is not defined" in Linux
Read more >
Bug #1412015 “NameError: global name 'WindowsError' is not defin ...
NameError: global name 'WindowsError' is not defined. Bug #1412015 reported by Ryne Everett on 2015-01-17. 16. This bug affects 3 people ...
Read more >
WindowsError is not available on linux? - Mailing List Archive
NameError : name 'WindowsError' is not defined > -- does this answer your question? Python 2.6.4 (r264:75706, Oct 28 2009, 23:01:00)
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