Problem z instalacją m2crypto z pip na OS X / macOS

pip install m2crypto

Generuje następujące wyjście:

building 'M2Crypto.__m2crypto' extension
swigging SWIG/_m2crypto.i to SWIG/_m2crypto_wrap.c
swig -python -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/include -I/usr/include/openssl -includeall -modern -o SWIG/_m2crypto_wrap.c SWIG/_m2crypto.i
SWIG/_m2crypto.i:30: Error: Unable to find 'openssl/opensslv.h'
SWIG/_m2crypto.i:33: Error: Unable to find 'openssl/safestack.h'
SWIG/_evp.i:12: Error: Unable to find 'openssl/opensslconf.h'
SWIG/_ec.i:7: Error: Unable to find 'openssl/opensslconf.h'
error: command 'swig' failed with exit status 1

Uciekłem:

brew install swig
Author: therealmarv, 2015-10-08

6 answers

Chciałem ładniejszego sposobu bez ręcznej instalacji i używania tylko Homebrew(który również domyślnie nie łączy openssl). Również użycie pip było wymogiem. Wydaje się, że działa to z najnowszym m2crypto 0.22.5. Przetestowałem go również raz z m2crypto 0.22.3 i wydaje się również działać. Wersja OpenSSL to 1.0.2 d:

brew install openssl
brew install swig

Wreszcie zainstalować m2crypto na macOS w Bash. Jest to długie polecenie, ale zmienia zmienne środowiskowe SWIG i clang tylko podczas pip install tak, że m2crypto otrzyma wszystkie wymagania OpenSSL:

env LDFLAGS="-L$(brew --prefix openssl)/lib" \
CFLAGS="-I$(brew --prefix openssl)/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I$(brew --prefix openssl)/include" \
pip install m2crypto

Btw. ostatnie polecenie działa również w przypadku użycia np. wymagań.txt.

Aktualizacja:
Dodatkowo polecenie dla użytkowników fish shell ...

env LDFLAGS="-L"(brew --prefix openssl)"/lib" \
CFLAGS="-I"(brew --prefix openssl)"/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I"(brew --prefix openssl)"/include" \
pip install m2crypto
 140
Author: therealmarv,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-06-10 13:19:22

Dzięki flagom therealmarv env udało mi się to uruchomić z wersją macports OpenSSL/ swig, oto co zrobiłem:

sudo port install openssl
sudo port install swig
sudo port install swig-python

Następnie użyj linii therealmarv, ale zamień "$(brew --prefix openssl) "na katalog z macports, który powinien być" /opt / local "

sudo env LDFLAGS="-L/opt/local/lib" \
CFLAGS="-I/opt/local/include" \
SWIG_FEATURES="-cpperraswarn -includeall -I/opt/local/include" \
pip install M2Crypto
 9
Author: hjjiang,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-10-17 07:12:10

Przechodziłem przez wiele bólu pracując w El Capitan. Oto co musiałem zrobić:

Zainstaluj OpenSSL (musisz użyć starszej wersji, m2crypto nie skompiluje się inaczej)

curl -O https://www.openssl.org/source/openssl-0.9.8zg.tar.gz
tar -xvzf openssl-0.9.8zg.tar.gz
cd openssl-0.9.8zg
./Configure --prefix=/usr/local darwin64-x86_64-cc
make && make test
sudo make install

Zainstaluj m2crypto

git clone https://github.com/martinpaljak/M2Crypto.git    
cd M2Crypto
python setup.py build build_ext --openssl=/usr/local
sudo python setup.py install build_ext --openssl=/usr/local

AFAIK jest zainstalowany... Ale nadal muszę zrobić kilka testów.

 4
Author: joebarbere,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-10-11 03:51:12

To naprawiło mój problem (Python 2.7):

export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
 1
Author: gmm,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-05-30 14:56:12

Na Ubuntu 18.04 LTS pojawił się dokładnie ten sam problem, podczas próby wykonania

pip install M2Crypto==0.24.0

Zrobił co następuje, aby się go pozbyć:

sudo apt-get install swig
sudo apt-get install libssl1.0-dev
 1
Author: Adriana Bentes,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2018-06-26 11:46:47

Sudo apt-get install python-m2crypto

 -10
Author: gaokun,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-10-19 03:26:47