1. 程式人生 > 實用技巧 >docker-compose 安裝問題:error: command 'i686-linux-gnu-gcc' failed with exit status 1

docker-compose 安裝問題:error: command 'i686-linux-gnu-gcc' failed with exit status 1

# sudo pip3.5 install docker-compose

安裝docker-compose的時候報錯如下:

  no previously-included directories found matching 'docs/_build'
  warning: no previously-included files found matching 'vectors'
  warning: no previously-included files matching '*' found under directory 'vectors'
  warning: no previously-included files found matching '.travis.yml'
  warning: no previously-included files found matching '.travis'
  warning: no previously-included files matching '*' found under directory '.travis'
  warning: no previously-included files matching '*' found under directory '.github'
  warning: no previously-included files found matching 'release.py'
  warning: no previously-included files found matching '.coveragerc'
  warning: no previously-included files found matching 'codecov.yml'
  warning: no previously-included files found matching 'dev-requirements.txt'
  warning: no previously-included files found matching 'rtd-requirements.txt'
  warning: no previously-included files found matching 'tox.ini'
  writing manifest file 'src/cryptography.egg-info/SOURCES.txt'
  running build_ext
  generating cffi module 'build/temp.linux-i686-3.5/_padding.c'
  creating build/temp.linux-i686-3.5
  generating cffi module 'build/temp.linux-i686-3.5/_openssl.c'
  building '_openssl' extension
  creating build/temp.linux-i686-3.5/build
  creating build/temp.linux-i686-3.5/build/temp.linux-i686-3.5
  i686-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -c build/temp.linux-i686-3.5/_openssl.c -o build/temp.linux-i686-3.5/build/temp.linux-i686-3.5/_openssl.o -Wconversion -Wno-error=sign-conversion
  build/temp.linux-i686-3.5/_openssl.c:546:30: fatal error: openssl/opensslv.h: No such file or directory
  compilation terminated.
  error: command 'i686-linux-gnu-gcc' failed with exit status 1
---------------------------------------- ERROR: Failed building wheel for cryptography Failed to build cryptography ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly

解決辦法:

sudo apt-get build-dep python-lxml

sudo pip install lxml --upgrade

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

pip install scrapy

以上執行完成後再重新安裝;

sudo pip3.5 install docker-compose

重新安裝沒有報錯:

Installing collected packages: PyYAML, certifi, idna, urllib3, chardet, requests, websocket-client, pycparser, cffi, cryptography, bcrypt, pynacl, paramiko, docker, zipp, importlib-metadata, pyrsistent, attrs, jsonschema, texttable, cached-property, docopt, dockerpty, python-dotenv, distro, docker-compose
Attempting uninstall: urllib3
Found existing installation: urllib3 1.13.1
Uninstalling urllib3-1.13.1:
Successfully uninstalled urllib3-1.13.1
Attempting uninstall: chardet
Found existing installation: chardet 2.3.0
Uninstalling chardet-2.3.0:
Successfully uninstalled chardet-2.3.0
Attempting uninstall: requests
Found existing installation: requests 2.9.1
Uninstalling requests-2.9.1:
Successfully uninstalled requests-2.9.1
ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts.

We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

jsonschema 3.2.0 requires six>=1.11.0, but you'll have six 1.10.0 which is incompatible.
Successfully installed PyYAML-5.3.1 attrs-19.3.0 bcrypt-3.1.7 cached-property-1.5.1 certifi-2020.6.20 cffi-1.14.1 chardet-3.0.4 cryptography-3.0 distro-1.5.0 docker-4.2.2 docker-compose-1.26.2 dockerpty-0.4.1 docopt-0.6.2 idna-2.10 importlib-metadata-1.7.0 jsonschema-3.2.0 paramiko-2.7.1 pycparser-2.20 pynacl-1.4.0 pyrsistent-0.16.0 python-dotenv-0.14.0 requests-2.24.0 texttable-1.6.2 urllib3-1.25.10 websocket-client-0.57.0 zipp-1.2.0
root@ubuntu:/home# docker-compose --version
docker-compose version 1.26.2, build unknown