読者です 読者をやめる 読者になる 読者になる

ansible をアップグレードしようとしたらエラー

pip install –upgrade ansible でエラー。

pip install --upgrade ansible
Collecting ansible
  Downloading ansible-2.2.1.0.tar.gz (2.5MB)
    100% |################################| 2.5MB 404kB/s 


  build/temp.macosx-10.10-x86_64-2.7/_openssl.c:1107:27: error: unknown type name 'EVP_PKEY_CTX'
  int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *);
                            ^
  fatal error: too many errors emitted, stopping now [-ferror-limit=]
  20 errors generated.
  error: command 'clang' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for cryptography
  Running setup.py clean for cryptography



    creating build/temp.macosx-10.10-x86_64-2.7/build/temp.macosx-10.10-x86_64-2.7
    clang -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kubotad/.pyenv/versions/2.7.9/include/python2.7 -c build/temp.macosx-10.10-x86_64-2.7/_openssl.c -o build/temp.macosx-10.10-x86_64-2.7/build/temp.macosx-10.10-x86_64-2.7/_openssl.o
    build/temp.macosx-10.10-x86_64-2.7/_openssl.c:680:30: error: expected function body after function declarator
    typedef LHASH_OF(CONF_VALUE) Cryptography_LHASH_OF_CONF_VALUE;
                                 ^
    build/temp.macosx-10.10-x86_64-2.7/_openssl.c:886:5: error: expected ')'
    DH *DHparams_dup(DH *);
        ^
    /usr/include/openssl/dh.h:164:25: note: expanded from macro 'DHparams_dup'
    #define DHparams_dup(x) ASN1_dup_of_const(DH,i2d_DHparams,d2i_DHparams,x)
                            ^


Command "/Users/kubotad/.pyenv/versions/app1/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip-build-UehdPg/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip-bUFtd6-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/kubotad/.pyenv/versions/app1/include/site/python2.7/cryptography" failed with error code 1 in /private/var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip-build-UehdPg/cryptography/

↑このコマンドは、後で気づいたけど
/Users/kubotad/PycharmProjects/app1/.python-version
というファイルがある場所で実行した。
なので、pyenvの中のpythonバージョンで実行されている。

sudoでやってみても失敗。

sudo pip install --upgrade ansible
Password:
The directory '/Users/kubotad/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/kubotad/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.


                        ^
    build/temp.macosx-10.10-x86_64-2.7/_openssl.c:1107:27: error: unknown type name 'EVP_PKEY_CTX'
    int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *);
                              ^
    fatal error: too many errors emitted, stopping now [-ferror-limit=]
    20 errors generated.
    error: command 'clang' failed with exit status 1
    
    ----------------------------------------
Command "/Users/kubotad/.pyenv/versions/app1/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-E79wWq/cryptography/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-wAEgKs-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/kubotad/.pyenv/versions/app1/include/site/python2.7/cryptography" failed with error code 1 in /private/tmp/pip-build-E79wWq/cryptography/

↓このコマンドは多分ホームディレクトリで実行した。

% pip install --upgrade ansible     
Downloading/unpacking ansible
  Downloading ansible-2.2.1.0.tar.gz (2.5MB): 2.5MB downloaded
  Running setup.py (path:/private/var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip_build_kubotad/ansible/setup.py) egg_info for package ansible



    changing mode of /Users/kubotad/.pyenv/versions/2.7.9/bin/ansible-pull to 755
    changing mode of /Users/kubotad/.pyenv/versions/2.7.9/bin/ansible-vault to 755
  Running setup.py install for PyYAML
    checking if libyaml is compilable
    clang -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/kubotad/.pyenv/versions/2.7.9/include/python2.7 -c build/temp.macosx-10.10-x86_64-2.7/check_libyaml.c -o build/temp.macosx-10.10-x86_64-2.7/check_libyaml.o
    build/temp.macosx-10.10-x86_64-2.7/check_libyaml.c:2:10: fatal error: 'yaml.h' file not found
    #include <yaml.h>
             ^
    1 error generated.
    
    libyaml is not found or a compiler error: forcing --without-libyaml
    (if libyaml is installed correctly, you may need to
     specify the option --include-dirs or uncomment and
     modify the parameter include_dirs in setup.cfg)
    
  Found existing installation: setuptools 7.0
    Uninstalling setuptools:
      Successfully uninstalled setuptools
  Running setup.py install for pycrypto
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/setuptools/__init__.py", line 10, in <module>
        from six.moves import filter, map
    ImportError: No module named six.moves
    Complete output from command /Users/kubotad/.pyenv/versions/2.7.9/bin/python2.7 -c "import setuptools, tokenize;__file__='/private/var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip_build_kubotad/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip-ijhgF2-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/setuptools/__init__.py", line 10, in <module>

    from six.moves import filter, map

ImportError: No module named six.moves

----------------------------------------
Cleaning up...
Command /Users/kubotad/.pyenv/versions/2.7.9/bin/python2.7 -c "import setuptools, tokenize;__file__='/private/var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip_build_kubotad/pycrypto/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip-ijhgF2-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/1s/14vkt60n019bjctmy0rvg6cm0000gn/T/pip_build_kubotad/pycrypto
Storing debug log for failure in /Users/kubotad/.pip/pip.log
~% pip install six
Downloading/unpacking six
  Downloading six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six
Cleaning up...
~% pip install setuptools
Requirement already satisfied (use --upgrade to upgrade): setuptools in ./.pyenv/versions/2.7.9/lib/python2.7/site-packages
Cleaning up...
[kubotad@Kubotads-iMac](19:34:07)~% 

Ansibleの修復

関連パッケージを変えたので試しに、ansible のバージョンを確認したらエラー。壊れた。

~% ansible --version
ERROR! Unexpected Exception: No module named markupsafe
the full traceback was:

Traceback (most recent call last):
  File "/Users/kubotad/.pyenv/versions/2.7.9/bin/ansible", line 80, in <module>
    from ansible.cli.adhoc import AdHocCLI as mycli
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/ansible/cli/adhoc.py", line 28, in <module>
    from ansible.executor.task_queue_manager import TaskQueueManager
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 29, in <module>
    from ansible.executor.play_iterator import PlayIterator
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/ansible/executor/play_iterator.py", line 30, in <module>
    from ansible.playbook.block import Block
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/ansible/playbook/__init__.py", line 27, in <module>
    from ansible.playbook.play import Play
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/ansible/playbook/play.py", line 27, in <module>
    from ansible.playbook.base import Base
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/ansible/playbook/base.py", line 29, in <module>
    from jinja2.exceptions import UndefinedError
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/jinja2/__init__.py", line 33, in <module>
    from jinja2.environment import Environment, Template
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/jinja2/environment.py", line 13, in <module>
    from jinja2 import nodes
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/jinja2/nodes.py", line 19, in <module>
    from jinja2.utils import Markup
  File "/Users/kubotad/.pyenv/versions/2.7.9/lib/python2.7/site-packages/jinja2/utils.py", line 531, in <module>
    from markupsafe import Markup, escape, soft_unicode
ImportError: No module named markupsafe
[kubotad@Kubotads-iMac](19:34:36)~% 
% pip install markupsafe
Downloading/unpacking markupsafe
  Downloading MarkupSafe-0.23.tar.gz
Cleaning up...
setuptools must be installed to install from a source distribution
Storing debug log for failure in /Users/kubotad/.pip/pip.log
% pip install -U pip
Downloading/unpacking pip from https://pypi.python.org/packages/b6/ac/7015eb97dc749283ffdec1c3a88ddb8ae03b8fad0f0e611408f196358da3/pip-9.0.1-py2.py3-none-any.whl#md5=297dbd16ef53bcef0447d245815f5144
  Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
Installing collected packages: pip
  Found existing installation: pip 1.5.6
    Uninstalling pip:
      Successfully uninstalled pip
Successfully installed pip
Cleaning up...
[kubotad@Kubotads-iMac](19:39:23)~% 
[kubotad@Kubotads-iMac](19:39:24)~% 
[kubotad@Kubotads-iMac](19:39:24)~% pip install setuptools
Requirement already satisfied: setuptools in ./.pyenv/versions/2.7.9/lib/python2.7/site-packages
Requirement already satisfied: six>=1.6.0 in ./.pyenv/versions/2.7.9/lib/python2.7/site-packages (from setuptools)
Collecting appdirs>=1.4.0 (from setuptools)
  Using cached appdirs-1.4.0-py2.py3-none-any.whl
Collecting packaging>=16.8 (from setuptools)
  Using cached packaging-16.8-py2.py3-none-any.whl
Collecting pyparsing (from packaging>=16.8->setuptools)
  Using cached pyparsing-2.1.10-py2.py3-none-any.whl
Installing collected packages: appdirs, pyparsing, packaging
Successfully installed appdirs-1.4.0 packaging-16.8 pyparsing-2.1.10

markupsafe がインストールできた。

~% pip install markupsafe
Collecting markupsafe
Installing collected packages: markupsafe
Successfully installed markupsafe-0.23

直った。

% ansible --version     
ansible 2.2.1.0
  config file = 
  configured module search path = Default w/o overrides

app1 env

pyenv に入っているpythonでは、まだAnsibleが2.1.0.0のままだった。

pip install --upgrade cryptography

を実行するとエラーになる。

% pip install -U pip
Requirement already up-to-date: pip in /Users/kubotad/.pyenv/versions/app1/lib/python2.7/site-packages

ansible==2.2.1.0 の環境

% pip freeze
ansible==2.2.1.0
appdirs==1.4.0
Jinja2==2.8.1
MarkupSafe==0.23
packaging==16.8
paramiko==2.1.1
pyparsing==2.1.10
PyYAML==3.12
six==1.10.0
virtualenv==15.0.2

ansible==2.1.0.0 の環境

% pip freeze        
amqp==1.4.9
ansible==2.1.0.0
anyjson==0.3.3
appdirs==1.4.0
billiard==3.3.0.23
boto==2.41.0
bpmappers==0.8.2
celery==3.1.23
cffi==1.9.1
Django==1.8.13
django-celery==3.1.17
django-kombu==0.9.4
ecdsa==0.13
enum34==1.1.6
Fabric==1.11.1
idna==2.2
ipaddress==1.0.18
Jinja2==2.8.1
kombu==3.0.35
MarkupSafe==0.23
packaging==16.8
paramiko==1.17.1
psycopg2==2.6.2
pyasn1==0.2.2
pycparser==2.17
pycrypto==2.6.1
pyparsing==2.1.10
pytz==2016.4
PyYAML==3.12
redis==2.10.5
six==1.10.0

openssl

openssl version

でバージョンを確認したら、0.9.8 だった。
upgradeしようとしてもすでにインストール済みというメッセージがでる。

http://stackoverflow.com/questions/36372000/warning-openssl-1-0-2g-already-installed-when-using-homebrew

http://stackoverflow.com/questions/15185661/update-openssl-on-os-x-with-homebrew

% brew link openssl --force
Linking /usr/local/Cellar/openssl/1.0.2h_1... 1601 symlinks created

opensslをアップグレードしたら、cryptography がインストールできるようになった。

pip install --upgrade cryptography

Successfully built cryptography
Installing collected packages: cryptography
Successfully installed cryptography-1.7.2

ansible

% pip install --upgrade ansible
Collecting ansible


Installing collected packages: paramiko, ansible
  Found existing installation: paramiko 1.17.1
    Uninstalling paramiko-1.17.1:
      Successfully uninstalled paramiko-1.17.1
  Found existing installation: ansible 2.1.0.0
    Uninstalling ansible-2.1.0.0:
      Successfully uninstalled ansible-2.1.0.0
Successfully installed ansible-2.2.1.0 paramiko-2.1.1

うまくいった。