Reputation: 29
I wanted to automatically deploy my django project by using Fabric3
Here is my fabfile.py
from fabric.api import env from fabric.api import run from fabric.operations import sudo GIT_REPO = "https://github.com/........" env.user = 'root' env.password = '...' env.hosts = ['demo....com'] env.port = '22' def deploy(): source_folder = '/home/.../sites/..../...' run('cd %s && git pull' % source_folder) run(""" cd {} && ../env/bin/pip install -r requirements.txt && ../env/bin/python3 manage.py collectstatic --noinput && ../env/bin/python3 manage.py migrate """.format(source_folder)) sudo('restart gunicorn-demo.charon.me') sudo('service nginx reload')
And here is how I run it:
python fabfile.py fab deploy
And finally here is the error:
Traceback (most recent call last): File "/Users/charon/Documents/PycharmProjects/try_blog/fabfile.py", line 1, in from fabric.api import env File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fabric/api.py", line 10, in from fabric.context_managers import (cd, hide, settings, show, path, prefix, File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fabric/context_managers.py", line 27, in from fabric.state import output, win32, connections, env File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fabric/state.py", line 9, in from fabric.network import HostConnectionCache, ssh File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/fabric/network.py", line 16, in from fabric.exceptions import NetworkError ImportError: cannot import name 'NetworkError'
Plz help me with this!!!!
Upvotes: 2
Views: 1647
Reputation: 1
Please try by just writing the below command might work in the working directory:
fab deploy
NOT :
python fabfile.py fab deploy
Upvotes: 0
Reputation: 59
fabric has two versions. Your code mismatch the version of fabric.
pip uninstall fabric
pip install 'fabric<2.0'
then things will be all right.
Upvotes: 1
Reputation: 181
Shouldn't it be fab -f fabfile.py deploy
Anyway, you probably have a messed up install, try:
which python
Does that match:
/Library/Frameworks/Python.framework/Versions/3.6/bin/python
Upvotes: 1