【发布时间】:2020-01-05 14:24:23
【问题描述】:
您好,我无法理解包管理器,例如 apt pip pip3
我正在尝试使用 fabric3 库自动执行 shell 命令
我正在关注一本书,它告诉我编写以下 shell 命令pip install fabric3
我的fabfile.py 包含仅适用于 python3 的 f 字符串
当我执行pip list 时,我看到Fabric3 (1.14.post1),所以我假设该软件包已成功安装,但是当我运行我的fab 时,我找不到fab,命令行告诉我sudo apt install fabric
但是这样做是没有用的,因为fabric 只适用于python2.7
基本上我已经想到了两种可能的解决方案:
1-试图使fab 命令使用python3.6 而不是python2.7?但我不知道该怎么做...
2-删除Fabric,保留Fabric3,但由于某种原因,我得到了这个'fab' not found,我不明白为什么
我已经阅读了文档,但它真的很晦涩,我找不到我的问题的答案
任何帮助将不胜感激, 谢谢
更新1:
所以当我运行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 安装正确
然后,我运行此命令在服务器上部署我的代码:
fab deploy:host=xxx@yyy
其中xxx 是用户名yyy 是域名
我收到以下错误:Command 'fab' not found, but can be installed with: sudo apt install fabric
注意:我试过这个命令update-alternatives --install /usr/bin/python python /usr/bin/python3.6 10
在这个话题上找到Unable to set default python version to python3 in ubuntu
而which python仍然指向/usr/bin/python
我发现我有/usr/bin/python3.6
你认为如果我设法让which python 指向/usr/bin/python3.6 我的问题会得到解决吗?
【问题讨论】:
-
在您的终端中运行:
which python以查看您使用的是哪个 python 版本。还有哪个操作系统 - 听起来像 linux? -
感谢您的回答
which python指向/usr/bin/python是Linux -
我确实尝试了
alias python=python3,因为我试图使用python3作为默认python版本 -
你能用你的脚本内容更新帖子吗?还有你如何运行它。
-
是的,已经更新了
标签: python deployment fabric