hibtc/cpymad

Installation on WIN

sterbini opened this issue · 12 comments

Hi,

I would like to install cpymad on WIN (10 Enterprise) using the simpleest approach.
I installed Anaconda Python 3.7 and used the instruction

pip install cpymad

All went fine but when I try

from cpymad.madx import Madx
myMad= Madx()

I get the following error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-727443018fae> in <module>
      1 from cpymad.madx import Madx
----> 2 myMad = Madx()

~\AppData\Local\Continuum\anaconda3\lib\site-packages\cpymad\madx.py in __init__(self, libmadx, command_log, stdout, history, **Popen_args)
    171             if callable(stdout):
    172                 self.reader = AsyncReader(self._process.stdout, stdout)
--> 173         if not libmadx.is_started():
    174             with self.reader:
    175                 libmadx.start()

~\AppData\Local\Continuum\anaconda3\lib\site-packages\minrpc\client.py in DeferredMethod(*args, **kwargs)
    158         def DeferredMethod(*args, **kwargs):
    159             return self.__client._request('function_call', self.__module,
--> 160                                           funcname, args, kwargs)
    161         return DeferredMethod

~\AppData\Local\Continuum\anaconda3\lib\site-packages\minrpc\client.py in _request(self, kind, *args)
    110                 self._conn.close()
    111                 raise RemoteProcessCrashed()
--> 112         return self._dispatch(response)
    113 
    114     def _communicate(self, message):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\minrpc\client.py in _dispatch(self, response)
    121         kind, args = response
    122         handler = getattr(self, '_dispatch_%s' % (kind,))
--> 123         return handler(*args)
    124 
    125     def _dispatch_exception(self, exc_type, message):

~\AppData\Local\Continuum\anaconda3\lib\site-packages\minrpc\client.py in _dispatch_exception(self, exc_type, message)
    129         raise type(exc_type.__name__, (exc_type,), {
    130             '__str__': lambda *args: message,
--> 131             '__init__': lambda *args: None})
    132 
    133     def _dispatch_data(self, data):

ImportError: Traceback (most recent call last):
  File "C:\Users\sterbini\AppData\Local\Continuum\anaconda3\lib\site-packages\minrpc\service.py", line 85, in _dispatch
    response = handler(*args)
  File "C:\Users\sterbini\AppData\Local\Continuum\anaconda3\lib\site-packages\minrpc\service.py", line 101, in _dispatch_function_call
    module = __import__(modname, None, None, '*')
ImportError: DLL load failed: The specified module could not be found.

Can you help me?
Thanks a lot!

Guido

Hi,

Is it 32 or 64 bit python?

What happens if you do python -c "import cpymad.libmadx as l; l.start()" ?

Can you get dependency walker (http://www.dependencywalker.com/) and open libmadx.pyd in the cpymad installation folder with it (see python -c "import cpymad; print(cpymad.__file__)". It should show if there are any dll dependencies missing and which ones. (collapse to topmost level and for highlighted entries).

I suspect the reason might be that msvcr100.dll is missing on your system (which I unfortunately have to link against for technical reasons at this time). The official solution would be to download MSVC redistributable package (https://social.technet.microsoft.com/Forums/windows/en-US/52f0bd37-9a08-41b6-bb43-fa01ef3ebc4a/msvcr100dll-is-missing?forum=w8itprogeneral). It might also work to only download only the dll from non-official sources, at the risk of catching a virus:)

Best, Thomas

Hi,
It is a 64 bit python.

By running the code you suggested

python -c "import cpymad.libmadx as l; l.start()"

I obtain the same error
(ImportError: DLL load failed: The specified module could not be found.)

This is the output of the depencywalker
image

Probably more than one dependency is missing.
Cheers,
G.

Probably more than one dependency is missing.

No. Collapse all nodes such that you can see only the top level. It should indicate only msvc100.dll and python in yellow, rest fine. Python will be found at runtime, and msvc100 has to be obtained separately.

However... What is not fine is that it shows python34.dll while you mentioned you use python3.7?

Is this from the package that was installed to your python3.7 installation?

Hi,
image
This is the screenshot when I collapse the nodes.

For this screenshot I am using the py34 env. But the problem in py34 is very similar to py37. (sorry for the confusion).

Cheers,
G.

Ok, then it seems fine except for missing msvcr100.dll. Can you try to obtain it and then try again?

Hi,

I installed the Visual C++ Redistributable Packages for Visual Studio 2012 and 2015.
I did not solve the problem.
Should I target a specific year? Thanks.
G.

The link I gave listed 2010.

I installed the Visual C++ Redistributable Packages for Visual Studio 2010 but I still have the problem. :(
Cheers,
G.

Does dependencywalker now find the msvcr100.dll? If not, can you search it and copy-paste it to current directory? If this is not the problem I will have to check up on this at some other time.

Hi, I tried today on win10, anaconda python 3.7 64bit and couldn't reproduce. Just to make sure:

  • can you copy the msvcr100.dll into the current directory from where you run the python command line, and try again.
  • can you show the output of python -c "import sysconfig; print(sysconfig.get_platform())" to make sure this is really a 64bit env
  • what's the exact name of the .pyd file? should be libmadx.cp37-win_amd64.pyd

(Best try on py37 because py34 has recently reached its end-of-life and is no longer supported by many packages)

@sterbini Is this problem still present, and if so did you try my suggestions? If not I will soon close this issue.

Finally I used a Docker solution running Linux, so I did not continue investigating. Please close this issue.
Thanks.