Hello I have trouble understanding packages manager such as apt
pip
pip3
I am trying to automate shell command with the use of fabric3
library
I am following a book which tells me to write the following shell command pip install fabric3
My fabfile.py
contains f-strings which are working on python3 only
when I do pip list
I see Fabric3 (1.14.post1)
so I am assuming that the package is successfully installed, yet when I run my fab
, I get fab not found, and command line is telling me to sudo apt install fabric
But doing so is useless, because fabric
is working only with python2.7
Basically I have thought of two possible solutions to my problem :
1- Trying to make the fab
command to use python3.6
instead of python2.7
? But I don't know how to do that ...
2- Deleting Fabric, and keeping Fabric3, but for some reason, I get this 'fab' not found
and I don't understand why
I have read the documentation but It is really obscur, I find no answer to my issue
Any help will be greatly appreciated, Thanks
Update1:
So when I run pip list
asn1crypto (0.24.0)
attrs (17.4.0)
Automat (0.6.0)
bcrypt (3.1.7)
blinker (1.4)
certifi (2018.1.18)
cffi (1.13.2)
chardet (3.0.4)
click (6.7)
cloud-init (19.2)
colorama (0.3.7)
command-not-found (0.3)
configobj (5.0.6)
constantly (15.1.0)
cryptography (2.8)
distro-info (0.18ubuntu0.18.04.1)
Fabric3 (1.14.post1)
httplib2 (0.9.2)
hyperlink (17.3.1)
idna (2.6)
incremental (16.10.1)
Jinja2 (2.10)
jsonpatch (1.16)
jsonpointer (1.10)
jsonschema (2.6.0)
keyring (10.6.0)
keyrings.alt (3.0)
language-selector (0.1)
MarkupSafe (1.0)
netifaces (0.10.4)
oauthlib (2.0.6)
PAM (0.4.2)
paramiko (2.7.1)
pip (9.0.1)
pyasn1 (0.4.2)
pyasn1-modules (0.2.1)
pycparser (2.19)
pycrypto (2.6.1)
pygobject (3.26.1)
PyJWT (1.5.3)
PyNaCl (1.3.0)
pyOpenSSL (17.5.0)
pyserial (3.4)
python-apt (1.6.4)
python-debian (0.1.32)
pyxdg (0.25)
PyYAML (3.12)
requests (2.18.4)
requests-unixsocket (0.1.5)
SecretStorage (2.3.1)
service-identity (16.0.0)
setuptools (39.0.1)
six (1.13.0)
ssh-import-id (5.7)
systemd-python (234)
Twisted (17.9.0)
ufw (0.36)
unattended-upgrades (0.1)
urllib3 (1.22)
wheel (0.30.0)
zope.interface (4.3.2)
Fabric3 is correctly installed
Then, I run this command to deploy my code on server : fab deploy:host=xxx@yyy
where xxx
is username
and yyy
is domain name
I get the following error : Command 'fab' not found, but can be installed with: sudo apt install fabric
NOTE: I tried this command update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10
found on this topic Unable to set default python version to python3 in ubuntu
and which python
stills points to /usr/bin/python
I have found that I have /usr/bin/python3.6
Do you think if I manage to have the which python
pointing to /usr/bin/python3.6
my issue will be solved?
First of all fabric3 is unauthorized fork of fabric as stated here:
unfortunately, the fabric3 entry on PyPI is an unauthorized fork of Fabric 1.x which we do not control. Once modern Fabric gets up to 3.x, 4.x etc, we'll likely continue distributing it via both fabric and fabric2 for convenience; there will never be any official fabric3, fabric4 etc.
In other words, fabric2 is purely there to help users of 1.x cross the 2.0 “major rewrite” barrier; future major versions will not be large rewrites and will only have small sets of backward incompatibilities.
Please be aware that you have two versions of Python installed on your system. python2.7
and python3.6
. When you call pip install PACKAGE_NAME
it invokes by default the pip
associated with ptyhon2.7
. To make sure which one is used type the following command pip --version
. I guess it will return something like this pip xxx from /usr/lib/python2.7/site-packages (python 2.7)
. Thus, you have to install pip
for python3.6
on your system. Please notice that you have then to use pip3
instead of pip
.
Uninstall fabri3 by executing the following command: pip uninstall fabric3
pip3 install fabric>=2.4.0
fab deploy
from the directory where you have your deploy script. Don't forget to give the name deploy
to your function which is responsible for the deploy like this: from fabric import Connection as connection, task
@task
def deploy(ctx):
with connection(host=host, user=user) as c:
c.run('pwd')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.