1. 在本机安装x64的nanomsg : https://blog.csdn.net/norsd/article/details/81285104
  2. 从GitHub 下载 nanomsg-python的 zip 文件: https://github.com/tonysimpson/nanomsg-python
  3. 把zip文件解压到 c:\nanomsg-python-master
  4. 以Administrator权限打开 Visual Studio 17 下的 x64 Native Tools Command Prompt (如果不使用这个环境,编译连接会出现 cannot run “rc.exe”错误)
  5. 把c:\Program Files\nanomsg\lib\nanomsg.lib 复制到 c:\nanomsg-python-master\下
  6. 路径到 c:\nanomsg-python-master
  7. python setup.py install
  8. 最后添加Path: c:\Program Files\nanomsg\bin (否则Python可能无法找到dll)
Generating code
Finished generating code
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\nanomsg
copying build\lib.win-amd64-3.6\nanomsg\version.py -> build\bdist.win-amd64\egg\nanomsg
copying build\lib.win-amd64-3.6\nanomsg\wrapper.py -> build\bdist.win-amd64\egg\nanomsg
copying build\lib.win-amd64-3.6\nanomsg\__init__.py -> build\bdist.win-amd64\egg\nanomsg
creating build\bdist.win-amd64\egg\nanomsg_wrappers
copying build\lib.win-amd64-3.6\nanomsg_wrappers\__init__.py -> build\bdist.win-amd64\egg\nanomsg_wrappers
copying build\lib.win-amd64-3.6\_nanomsg_cpy.cp36-win_amd64.pyd -> build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\_nanomsg_ctypes
copying build\lib.win-amd64-3.6\_nanomsg_ctypes\__init__.py -> build\bdist.win-amd64\egg\_nanomsg_ctypes
byte-compiling build\bdist.win-amd64\egg\nanomsg\version.py to version.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\nanomsg\wrapper.py to wrapper.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\nanomsg\__init__.py to __init__.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\nanomsg_wrappers\__init__.py to __init__.cpython-36.pyc
byte-compiling build\bdist.win-amd64\egg\_nanomsg_ctypes\__init__.py to __init__.cpython-36.pyc
creating stub loader for _nanomsg_cpy.cp36-win_amd64.pyd
byte-compiling build\bdist.win-amd64\egg\_nanomsg_cpy.py to _nanomsg_cpy.cpython-36.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying nanomsg.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying nanomsg.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying nanomsg.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying nanomsg.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
writing build\bdist.win-amd64\egg\EGG-INFO\native_libs.txt
zip_safe flag not set; analyzing archive contents...
__pycache__._nanomsg_cpy.cpython-36: module references __file__
creating dist
creating 'dist\nanomsg-1.0-py3.6-win-amd64.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing nanomsg-1.0-py3.6-win-amd64.egg
creating c:\python36\lib\site-packages\nanomsg-1.0-py3.6-win-amd64.egg
Extracting nanomsg-1.0-py3.6-win-amd64.egg to c:\python36\lib\site-packages
Adding nanomsg 1.0 to easy-install.pth file

Installed c:\python36\lib\site-packages\nanomsg-1.0-py3.6-win-amd64.egg
Processing dependencies for nanomsg==1.0
Finished processing dependencies for nanomsg==1.0

最后就可以在python环境中运行”hello nanomsg” 的 Example了

from nanomsg import Socket, PAIR, PUB
s1 = Socket(PAIR)
s2 = Socket(PAIR)
s1.bind('inproc://bob')
s2.connect('inproc://bob')
s1.send(b'hello nanomsg')
print(s2.recv())
s1.close()
s2.close()
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐