Reputation: 768
I'm running Django with python3.2, and recently discovered that fabric doesn't support Python3.
So I created a second virtual environment (fabric-env) just to run fabric out of.
Here's the fab --version output from the virtualenv:
Fabric 1.9.0
Paramiko 1.14.0
python --version
Python 2.7.3
My fab file looks like this (only relevant lines):
from fabric.api import local
def deploy(branch_name):
with lcd('/var/www/finance'):
local('git pull /home/user1/dev/' + branch_name)
local('/var/www/finance/finance-env/bin/python3 manage.py test corefinance')
local('/var/www/finance/finance-env/bin/python3 manage.py schemamigration corefinance --auto')
local('/var/www/finance/finance-env/bin/python3 manage.py migrate corefinance')
local('sudo service apache2 restart')
When I run this deploy function, I'm getting the following error:
File "/var/www/finance/fabfile.py", line 19, in deploy
with lcd('/var/www/finance'):
NameError: global name 'lcd' is not defined
The fabric documentation says this function should be available. It appears both fabric and Python are recent enough ( just to be sure fabric is not trying to run off of the different Python, I ran this function both inside and outside my virtual environment).
No hits on Google for the error message...
Upvotes: 1
Views: 1269
Reputation: 122476
You have not imported lcd
. Add the following to the top of your file:
from fabric.context_managers import lcd
Upvotes: 2