Cannot import zmq in python (install issue)

旧时模样 提交于 2019-12-05 09:42:46
Jono

After much effort, I went back to basics and managed to get it working by:

Building from source with:

brew install zeromq
...
python setup.py configure --zmq=/usr/local/Cellar/zeromq/4.0.3/
...
sudo python setup.py install
...

or

sudo port install 
...

I have no idea why the standard methods didn't work, but at least I have pyzmq working :)

Got similar ImportError exceptions with OSX/MacPorts, installing the ZeroMQ lib with sudo port install zeromq fixed it for me.

Ekaterina Besse

Spent a lot of time with this problem, finally this worked for me:

  • brew install zeromq

  • find the foulder where libzmq.pc is hidden (Example in my case: Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx-x86_64/Canopy.app/Contents/lib/pkgconfig)

  • then make:

    export PKG_CONFIG_PATH=<path_found_above>
    

    Example in my case:

    export PKG_CONFIG_PATH=/Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx-x86_64/Canopy.app/Contents/lib/pkgconfig
    

i think the issue is the python installed is compiled with "--enable-unicode=ucs4",

>>> import sysconfig
>>> sysconfig.get_config_var('Py_UNICODE_SIZE')
>>> 4

and a solution to recompile python is described here in https://github.com/yyuu/pyenv/issues/257#issuecomment-195836492 if you use pyenv.

$pyenv uninstall 2.7.11
$PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2" pyenv install 2.7.11

then recreate your virtualenv, reinstall every package...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!