Integration of numpy

Hi,

If I try to add numpy to the site-packages folder and import it in a python script, this error occurs:

Traceback (most recent call last):
 File "DistanceRing::PythonScript", line 3, in <module>
 File "C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\__init__.py", line 142, in <module>
 from . import add_newdocs
 File "C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
 from numpy.lib import add_newdoc
 File "C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
 from .type_check import *
 File "C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
 import numpy.core.numeric as _nx
 File "C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\core\__init__.py", line 24, in <module>
 raise ImportError(msg)
 ImportError:
 Importing the multiarray numpy extension module failed. Most
 likely you are trying to import a failed build of numpy.
 If you're working with a numpy git repo, try git clean -xdf (removes all
 files not under version control). Otherwise reinstall numpy.
I searched this forum and found this and this thread, but couldn't solve my problem with it. Also i googled and tried to resolve all dependencies, but nothing seems to work. Did someone of you already try to make numpy work?

Regards Lumb3rjack

I would suggest submitting a support ticket. For example, there was an issue with not being able to import and use PIL, but now it is fixed and supported (I am not sure if it was in 4.0.3, but it will definitely work in 4.0.4).

 

I’m assuming you installed numpy to a fresh python environment and then copied the files over?

Thanks for the replies.

I’m assuming you installed numpy to a fresh python environment and then copied the files over?
Yes i did that, with a python 2.7.1 environment

 

I would suggest submitting a support ticket. For example, there was an issue with not being able to import and use PIL, but now it is fixed and supported (I am not sure if it was in 4.0.3, but it will definitely work in 4.0.4).
I'm so used to only getting help from forums, that I really didn't thought about that.

It doesn’t work in the current Version 4.0.5… :frowning:

Following Error when try to import numpy

Traceback (most recent call last):
File “Control Servo - End::PythonScript_ServoX”, line 2, in <module>
File “C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy_init_.py”, line 142, in <module>
from . import add_newdocs
File “C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\add_newdocs.py”, line 13, in <module>
from numpy.lib import add_newdoc
File “C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\lib_init_.py”, line 8, in <module>
from .type_check import *
File “C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\lib\type_check.py”, line 11, in <module>
import numpy.core.numeric as nx
File "C:\Program Files\Visual Components\Visual Components Professional 4.0\Python\Lib\site-packages\numpy\core_init
.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you’re working with a numpy git repo, try git clean -xdf (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: DLL load failed: Das angegebene Modul wurde nicht gefunden.

 

In Idle (on the same computer) with the same pip install numpy works!

Has anyone solved the problem?

I also have this problem. Tried pip install numpy in another Python 2.7 installation, and copied the two resulting folders from site-packages folder. Got the same error as Captain_feature above.

Please add support for numpy!

https://docs.scipy.org/doc/numpy-1.14.1/neps/dropping-python2.7-proposal.html

So if I need to do mathmatical analysis and data analysis, such as time series and FFT, is there any library that I can work with that is compatible as a third party library in VC, or is my only option to some how get the data out of VC and run my analysis “outside” via an external interpreter?

What is the best way to go about this if I need to run data analysis that requires python libraries such as numpy, pandas scipy?

 

I would say that VC is unlikely to ever support all the libraries one might want to use, because any C modules need to both support the stackless Python and be compiled with the correct toolchain to work. The Python in VC is really meant just for simulation configuration and implementing simulation logic, its not a general-purpose Python environment in that sense.

If you only need to do “offline” analysis of data, i.e. the results aren’t needed during simulation, using external environment for that should be pretty straight-forward. You can write files from VC Python scripts and use e.g. Pickle to serialize your data. It should be also possible to run shell commands from VC Python so you could e.g. trigger your external Python 3 code automatically and read results back to VC if needed. This way your data transfer and analysis execution can be fully automatic.

With external environment you of course gain the comforts of advanced IDEs, package managers, debugging etc. so it can be easier and faster to develop your analysis there anyway.

1 Like

Thanks for the fast reply Tsy,

I have some further question that maybe you can help me with :slight_smile:

My goal is to run the data analysis during simulation, and my simulation will generate signals as time series that I want to run analysis on, and as you say, for further development the python interpreter within VC is actually not suited for this kind of tasks.

So, to make my work easier, I think I will let VC-simulation generate my signals as time series, and all the analysis of these signals will be handled outside with an external environment. My question: what is the best way to “send” my signals generated in VC to an external Python interpreter? In previous cases I have been using socket programming, where I send the data via local host to my external interpreter. Is this the way to go also in this case, or are there other ways that I should consider?

Thanks for your time//

 

If you need to send data continuously then a socket connection does seem like a pretty good option. Sending data out from VC should be pretty easy, but receiving can be tricky because you don’t want to block the simulation thread when waiting for data. Mainly its a performance issue.

There are lots of networking libraries for Python but those are also unlikely to work in VC environment because of the stackless Python related threading limitations.