Skip to content
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

py2.7.5 fab error: ImportError: cannot import name NetworkError #1821

Closed
neemxyang opened this issue Jul 12, 2018 · 6 comments
Closed

py2.7.5 fab error: ImportError: cannot import name NetworkError #1821

neemxyang opened this issue Jul 12, 2018 · 6 comments

Comments

@neemxyang
Copy link

File "/usr/lib/python2.7/site-packages/fabric/network.py", line 16, in
from fabric.exceptions import NetworkError
ImportError: cannot import name NetworkError
what can I do?

@neemxyang
Copy link
Author

no one can answer me?

@rpkilby
Copy link
Contributor

rpkilby commented Jul 13, 2018

Hi @neemxyang - there isn't really enough information to go on. It looks like you're using Fabric 1, and there's nothing that would indicate why those imports fail.

My suggestion would be uninstall and reinstall Fabric into your environment and see if that fixes the issue. If that doesn't work, try creating a fresh virtual environment and installing Fabric into that. Keep in mind that you'll need to use Fabric 1.x, as 2.x doesn't support Python 2.

@ploxiln
Copy link

ploxiln commented Jul 13, 2018

Fabric-2.x does support Python 2.7, it's just that Fabric-1.x does not support Python 3

The error originally posted here, on its own, seems impossible. Maybe there's a very serious pip install or python path problem such that fabric is not really installed. We'd need much more information to be able to provide any help at all.

@rpkilby
Copy link
Contributor

rpkilby commented Jul 13, 2018

Fabric-2.x does support Python 2.7, it's just that Fabric-1.x does not support Python 3

Thanks - I've been working on a few packages that have dropped Python 2 support and forgot that Fabric was not the one of them.

@bitprophet
Copy link
Member

I'm just that slow, only adding 3 around when others start to drop 2 😂

Also, yea I don't get this error, either the package is installed incorrectly (the usual cause of import errors like this - setuptools causing a problem) or one is trying to follow version 1 docs with version 2 installed.

@nullx5
Copy link

nullx5 commented Jul 21, 2019

I was getting the following error when executing a fabric script I was using Python 3.5.3

** from fabric.exceptions import NetworkError
ImportError: can not import name 'NetworkError' **

I solve it by removing fabric inside my virtualenv and installing fabric3:
#pip uninstall fabric
#pip install fabric3

(venv-book-tuto) root@cs-6000-devshell-vm-842dba28-6daa-4d35-9b97-4b7c0ff7b2db:/home/<user>/venv-book-tuto/django# fab configure_postgres
Traceback (most recent call last):
  File "/home/<user>/venv-book-tuto/bin/fab", line 10, in <module>
    sys.exit(program.run())
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/invoke/program.py", line 352, in run
    self.parse_collection()
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/invoke/program.py", line 444, in parse_collection
    self.load_collection()
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/fabric/main.py", line 82, in load_collection
    super(Fab, self).load_collection()
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/invoke/program.py", line 661, in load_collection
    module, parent = loader.load(coll_name)
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/invoke/loader.py", line 76, in load
    module = imp.load_module(name, fd, path, desc)
  File "/home/<user>/venv-book-tuto/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/home/<user>/venv-book-tuto/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 693, in _load
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 673, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/<user>/venv-book-tuto/django/fabfile.py", line 42, in <module>
    from fabric.api import *
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/fabric/api.py", line 10, in <module>
    from fabric.context_managers import (cd, hide, settings, show, path, prefix,
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/fabric/context_managers.py", line 27, in <module>
    from fabric.state import output, win32, connections, env
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/fabric/state.py", line 9, in <module>
    from fabric.network import HostConnectionCache, ssh
  File "/home/<user>/venv-book-tuto/lib/python3.5/site-packages/fabric/network.py", line 16, in <module>
    from fabric.exceptions import NetworkError
ImportError: cannot import name 'NetworkError'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants