nanomsg-python icon indicating copy to clipboard operation
nanomsg-python copied to clipboard

import nanomsg ERROR

Open lijincan opened this issue 12 years ago • 9 comments

C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg\nanomsg_wrappers__init__.py:22: UserWarning: Could not load the default wrapper for your platform: cpy, performance may be affected! "%s, performance may be affected!") % (default,)) Traceback (most recent call last): File "F:\eclipse_projects\test\nanomsq_t1.py", line 3, in import nanomsg File "C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg\nanomsg__init__.py", line 7, in from . import wrapper File "C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg\nanomsg\wrapper.py", line 4, in wrapper = load_wrapper() File "C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg\nanomsg_wrappers__init.py", line 23, in load_ wrapper return importlib.import_module('nanomsg_ctypes') File "C:\Python27\lib\importlib__init_.py", line 37, in import_module import(name) File "C:\Python27\Lib\site-packages\nanomsg-1.0a2-py2.7-win-amd64.egg_nanomsg_ctypes__init__.py", line 10, in lib = ctypes.windll.nanomsg File "C:\Python27\lib\ctypes__init_.py", line 423, in getattr dll = self.dlltype(name) File "C:\Python27\lib\ctypes__init_.py", line 353, in init self._handle = _dlopen(self._name, mode) WindowsError: [Error 126]

lijincan avatar Nov 01 '13 06:11 lijincan

Hi, If you add the nanomsg.dll to your PATH this should work, but it will be using the ctypes backend which is a bit slower.

I'm afraid building the library from source on windows is a bit hard. I will upload binaries for windows to PyPI as soon as I can.

tonysimpson avatar Nov 01 '13 16:11 tonysimpson

Hi, add the nanomsg.dll to PATH can't solve the problem ;( still the same error

lijincan avatar Nov 05 '13 05:11 lijincan

Hi, any progress on windows support? Building nanomsg sources was easy part but I cannot make nanomsg-python work.

vac avatar Feb 16 '15 13:02 vac

I have manage to make it work on windows. Maybe my tips would be usefull for someone.

Requirements: visual studio, cmake

  • download nanomsg c sources.
  • build nanomsg c sources (as described on nanomsg website (http://nanomsg.org/development.html). i.e.:
    • make build directory in nanomsg sources dir
    • run cmake .. from build dir
    • build nanomsg sources, in my case I'v made it from command line:
      • First I had to run vcvarsall.bat (which resides somewhere in visual studio directory)
      • and I build library by runing: msbuild nanomsg.sln /t:Build /p:Configuration=Release

after this step you should find nanomsg.lib and nanomsg.dll in Release (or Debug) directory.

  • copy nanomsg.lib to your \libs directory after this step simillar patch should exists in your system: c:\python27\libs\nanomsg.lib
  • make nanomsg directory in your \include directory.
  • copy nanomsg c sources to your \include\nanomsg after this step simillar patch should exists in your system: c:\python27\include\nanomsg\nn.h
  • finally try to install python nanomsg: python setup.py install

now you can start to use nanomsg in python - BUT YOU NEED: nanomsg.dll in directory from which you run script.

If there is no nanomsg.dll you will get exception after import nanomsg (WindowsError: [Error 126] ....).

If it's working you can delete \libs\nanomsg.lib file and \include\nanomsg\ directory

It would be nice to make it easier - maybe someone knows easy way to make binary package installer with nanomsg.dll included.

If you like to I can send you binary installer of python module "nanomsg-1.0.win32-py2.7.exe" (made with python setup.py bdist --format=wininst) and a nanomsg.dll.

vac avatar Apr 10 '15 10:04 vac

@vac thanks pal. it solved my problem.

uwydoc avatar Jun 17 '15 06:06 uwydoc

You can create a complete windows installer (that contains the compiled dll) by adding the following line to setup.py

setup( name='nanomsg', version=version, packages=[str('nanomsg'), str('_nanomsg_ctypes'), str('nanomsg_wrappers')], data_files=[('lib\site-packages',["C:\Dev\external\nanomsg\x64\Release\nanomsg.dll"])], ...

of course change the path to nanomsg.dll

0xshlomil avatar Oct 20 '15 11:10 0xshlomil

yeah windows installer is nice but unfortunately python lib/site-packages are not in windows PATH by default.. So your app/script which is using nanomsg still cannot find dll...

vac avatar Oct 21 '15 05:10 vac

Ok it's now much better. I'v made windows installer with dll included as @shluvme suggested: setup.py:

data_files=[('lib/site-packages',["../nanomsg/nanomsg.dll",])]

setup(
    name='nanomsg',
    version=__version__,
    packages=[str('nanomsg'), str('_nanomsg_ctypes'), str('nanomsg_wrappers')],
    data_files = data_files,

dll would be copied to python site-pakcages. To make sure that it's directory would be included in system PATH I'v added following code to nanomsg/init.py:

from __future__ import division, absolute_import, print_function, unicode_literals

from .version import __version__
from struct import Struct as _Struct
import warnings

#-----HERE:-------
import distutils.sysconfig 
import os 
os.environ['PATH'] += ';'+distutils.sysconfig.get_python_lib() 
#-----------------

from . import wrapper

This way everytime nanomsg is imported the site-packages are added to system path and nanomsg.dll can be found by wrapper. Installer is made with python setup.py bdist_wininst.

vac avatar Oct 21 '15 07:10 vac

ps. if you would like to test my windows build I'v put installer here: http://vacu.la/python/nanomsg-1.0.win32-py2.7.exe

warning: nanomsg and nanomsg-python code which was used to generate dll and installer is not recent (april 2015)

vac avatar Oct 21 '15 07:10 vac