错误处理:由于环境错误,无法安装包:[Errno 1] 操作不允许

解决安装Ansible时出现的错误备忘录

$ sudo pip3 install ansible
...
Collecting MarkupSafe>=0.23 (from jinja2->ansible)
Collecting pycparser (from cffi!=1.11.3,>=1.7->cryptography->ansible)
Installing collected packages: pycparser, cffi, six, idna, asn1crypto, cryptography, bcrypt, pynacl, pyasn1, paramiko, PyYAML, MarkupSafe, jinja2, ansible
Could not install packages due to an EnvironmentError: [Errno 1] Operation not permitted: '/bin/ansible-console'

似乎在/bin目录下,即使使用sudo也无法放置文件。
因此,我们可以通过在pip命令中加入–user选项来更改安装位置。

pip3 install ansible --user

我的Mac环境安装在/Users/paper2/Library/Python/3.7/bin上,因此设置了路径并成功安装。

顺便提一下,确认密码的方法如下所示:

$ pip3 show ansible
Name: ansible
Version: 2.6.3
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: info@ansible.com
License: GPLv3+
Location: /Users/XXXX/Library/Python/3.7/lib/python/site-packages
Requires: paramiko, setuptools, cryptography, jinja2, PyYAML
Required-by:
广告
将在 10 秒后关闭
bannerAds