1. 程式人生 > >nanomsg-python 安裝在Windows下的流程

nanomsg-python 安裝在Windows下的流程

  1. 把zip檔案解壓到 c:\nanomsg-python-master
  2. 以Administrator許可權開啟 Visual Studio 17 下的 x64 Native Tools Command Prompt (如果不使用這個環境,編譯連線會出現 cannot run “rc.exe”錯誤)
  3. 把c:\Program Files\nanomsg\lib\nanomsg.lib 複製到 c:\nanomsg-python-master\下
  4. 路徑到 c:\nanomsg-python-master
  5. python setup.py install
  6. 最後新增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()