Rhino 6.0, error: No module name numpy

Hi,

Sorry for the inconvenience.

I managed to get topop_numpy working with a normal python script that I wrote.

a working topop.py

(compas-dev) C:\Users\Rick>python c:/Users/Rick/testingvscode/topop.py
Testing topop with topop.py within conda environment
Iteration: 1 Compliance: 9.261e+13
Iteration: 2 Compliance: 2.326e+14
Iteration: 3 Compliance: 3.279e+14
Iteration: 4 Compliance: 1.371e+14

But still nothing within GH. I created a new environment with the following packages in it:

Active packages

packages in environment at C:\Users\Rick\Miniconda3\envs\compas-dev:

Name Version Build Channel

blas 1.0 mkl
ca-certificates 2019.11.28 hecc5488_0 conda-forge
certifi 2019.11.28 py37_0 conda-forge
compas 0.11.4 py37_0 conda-forge
cycler 0.10.0 py_2 conda-forge
cython 0.29.14 py37h6538335_0 conda-forge
decorator 4.4.1 py_0 conda-forge
fastcache 1.1.0 py37hfa6e2cd_0 conda-forge
freetype 2.10.0 h563cfd7_1 conda-forge
icc_rt 2019.0.0 h0cc432a_1
icu 64.2 he025d50_1 conda-forge
intel-openmp 2019.4 245
jpeg 9c hfa6e2cd_1001 conda-forge
kiwisolver 1.1.0 py37he980bc4_0 conda-forge
libblas 3.8.0 14_mkl conda-forge
libcblas 3.8.0 14_mkl conda-forge
libclang 9.0.0 default_hf44288c_4 conda-forge
liblapack 3.8.0 14_mkl conda-forge
libpng 1.6.37 h7602738_0 conda-forge
libtiff 4.1.0 h21b02b4_1 conda-forge
llvmlite 0.30.0 py37_0 conda-forge
lz4-c 1.8.3 he025d50_1001 conda-forge
matplotlib 2.2.4 py37_2 conda-forge
matplotlib-base 2.2.4 py37h2981e6d_2 conda-forge
mkl 2019.4 245
mkl-service 2.3.0 py37hfa6e2cd_0 conda-forge
mpmath 1.1.0 py_0 conda-forge
networkx 2.4 py_0 conda-forge
numba 0.46.0 py37he350917_1 conda-forge
numpy 1.17.3 py37hc71023c_0 conda-forge
olefile 0.46 py_0 conda-forge
openssl 1.1.1d hfa6e2cd_0 conda-forge
pillow 6.2.1 py37h5fcff3f_1 conda-forge
pip 19.3.1 py37_0 conda-forge
planarity 3.0.0.5 hfa6e2cd_1002 conda-forge
pyparsing 2.4.5 py_0 conda-forge
pyqt 5.12.3 py37h6538335_1 conda-forge
pyqt5-sip 4.19.18 pypi_0 pypi
pyqtwebengine 5.12.1 pypi_0 pypi
python 3.7.3 h510b542_1 conda-forge
python-dateutil 2.8.1 py_0 conda-forge
python-planarity 0.4.1 py37hfa6e2cd_2 conda-forge
pytz 2019.3 py_0 conda-forge
qt 5.12.5 h7ef1ec2_0 conda-forge
scipy 1.3.2 py37h29ff71c_0
setuptools 42.0.2 py37_0 conda-forge
six 1.13.0 py37_0 conda-forge
sqlite 3.30.1 hfa6e2cd_0 conda-forge
sympy 1.4 py37_0 conda-forge
tk 8.6.10 hfa6e2cd_0 conda-forge
tornado 6.0.3 py37hfa6e2cd_0 conda-forge
vc 14.1 h0510ff6_4
vs2015_runtime 14.16.27012 hf0eaf9b_0
wheel 0.33.6 py37_0 conda-forge
wincertstore 0.2 py37_1003 conda-forge
xz 5.2.4 h2fa13f4_1001 conda-forge
zlib 1.2.11 h2fa13f4_1006 conda-forge
zstd 1.4.4 hd8a0e53_1 conda-forge

In this chart both SciPy and NumPy are clearly in this environment. I removed compas from ironpython and reinstalled it in this env, but (with the same script as topop.py, only including XFunc) it won’t work within GH. Any tips?

Thanks for you time

Rick

could it be that you have a Python executable registered on your path?
is miniconda on your path?
what do you mean by “i removed compas from ironpython”?

what happens when you start the proxy server from the command line and run the topop algorithm?

# Anaconda Prompt
conda activate compas-dev
python
>>> from compas.rpc import Proxy
>>> p = Proxy('compas.numerical')
>>> p.stop_server()
>>> p.start_server()
>>> loads = {'0-50': [1, 0], '0-100': [1, 0], '0-150': [1, 0], '0-200': [1, 0]}
>>> supports = {'0-0': [1, 1], '50-0': [1, 1], '100-0': [1, 1]}
>>> x = p.topop_numpy(100, 200, loads, supports, volfrac=0.3)
>>> print(x)

M̶i̶n̶i̶c̶o̶n̶d̶a̶ ̶i̶s̶ ̶o̶n̶ ̶m̶y̶ ̶p̶a̶t̶h̶.̶

S̶o̶r̶r̶y̶ ̶I̶ ̶m̶e̶a̶n̶t̶ ̶t̶h̶a̶t̶ ̶I̶ ̶u̶n̶i̶n̶s̶t̶a̶l̶l̶e̶d̶ ̶c̶o̶m̶p̶a̶s̶.
Th̶e̶ ̶s̶c̶r̶i̶p̶t̶ ̶s̶e̶e̶m̶s̶ ̶t̶o̶ ̶w̶o̶r̶k̶ ̶p̶e̶r̶f̶e̶c̶t̶l̶y̶ ̶(̶I̶ ̶g̶e̶t̶ ̶a̶ ̶l̶a̶r̶g̶e̶ ̶a̶r̶r̶a̶y̶,̶ ̶w̶h̶i̶c̶h̶ ̶s̶h̶o̶u̶l̶d̶ ̶b̶e̶ ̶t̶h̶e̶ ̶o̶u̶t̶p̶u̶t̶)̶

I just now decided to put this in GHPython and it worked! I think I messed up the dictionary or something in the input.

Pic in GH

Thank you so much! Brilliant!

Have a nice day!

Rick

Hi Tom, or whomever, Diederik here!

I thought today it would be a good day to try compas, and specifically try to use compas_ags in Grasshopper. I’m very close, but running into an error similar to this post

I tried the above topop script, and it works fine either in Anaconda prompt or Sublime, like so:

from compas.numerical import topop_numpy
loads = {‘0-50’: [1, 0], ‘0-100’: [1, 0], ‘0-150’: [1, 0], ‘0-200’: [1, 0]}
supports = {‘0-0’: [1, 1], ‘50-0’: [1, 1], ‘100-0’: [1, 1]}
x = topop_numpy(100, 200, loads, supports, volfrac=0.3)

However, in a GHPython component, like so:

from compas.rpc import Proxy
p = Proxy(‘compas.numerical’)
loads = {‘0-50’: [1, 0], ‘0-100’: [1, 0], ‘0-150’: [1, 0], ‘0-200’: [1, 0]}
supports = {‘0-0’: [1, 1], ‘50-0’: [1, 1], ‘100-0’: [1, 1]}
x = p.topop_numpy(100, 200, loads, supports, volfrac=0.3)

I get this:

Runtime error (Exception): Traceback (most recent call last):
File “C:\Anaconda3\lib\site-packages\compas\rpc\dispatcher.py”, line 89, in dispatch
module = importlib.import_module(modulename)
File "C:\Anaconda3\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1014, in _gcd_import
File “”, line 991, in find_and_load
File “”, line 975, in find_and_load_unlocked
File “”, line 671, in load_unlocked
File “”, line 783, in exec_module
File “”, line 219, in call_with_frames_removed
File "C:\Anaconda3\lib\site-packages\compas\numerical_init
.py", line 96, in
from .linalg import * # noqa: F401 F403
File “C:\Anaconda3\lib\site-packages\compas\numerical\linalg.py”, line 28, in
from scipy.sparse.linalg import factorized
File "C:\Anaconda3\lib\site-packages\scipy\sparse\linalg_init
.py", line 114, in
from .eigen import *
File "C:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen_init
.py", line 9, in
from .arpack import *
File "C:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack_init
.py", line 20, in
from .arpack import *
File “C:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py”, line 43, in
from . import _arpack
ImportError: DLL load failed while importing _arpack: The specified procedure could not be found.
Traceback:
line 332, in _proxy, “C:\Users\Summum 01\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\compas\rpc\proxy.py”
line 10, in script

I get similar errors trying to use compas_ags example scripts in GH (which also work fine in Anaconda prompt / Sublime), so I thought the errors are related, and I’d try getting this topop script to work first.

Going through the forum, it does seem I made the faux-pas of installing everything in the base environment. Is that the cause?

I’m running numpy 1.18.5, scipy 1.5.0, compas 0.16.2. In installed 64-bit Anaconda 3.8.3 in C:\Anaconda3. In Rhino, it’s running 64-bit IronPython 2.7.8.

Any thoughts on what to try?

hi diederik,

good to hear from you. hope all is well :slight_smile:

could you first try a combination of both: run the proxy version of the script from the terminal (if on windows, use the Anaconda Prompt). so something like

(base) > python
>>> from compas.rpc import Proxy
>>> p = Proxy('compas.numerical')
>>> p.restart_server()
>>> loads = {'0-50': [1, 0], '0-100': [1, 0], '0-150': [1, 0], '0-200': [1, 0]}
>>> supports = {'0-0': [1, 1], '50-0': [1, 1], '100-0': [1, 1]}
>>> x = p.topop_numpy(100, 200, loads, supports, volfrac=0.3)
>>> x

maybe also print the compas version and let me know what that is so i don’t make you try things that are not available in the version that you have (with the semester starting soon updates are frequent… p.restart_server() might for example not be available in the version you have. you could also use p.stop_server() and p.start_server())

>>> import compas
>>> compas.__version__

regardless of the outcome, it is indeed not a good idea to use the base environment for anything. you can consider it a bit as part of the “operating system” of conda and it therefore should be left alone (this is also highly encouraged by the peeps from Anaconda).

i am fairly certain the problem will go away by resetting the base environment, making a new one (e.g. summum) and trying again. you could do this by reverting the base environment (conda install revision 1) and possibly updating conda itself (conda update conda) after that.

if that doesn’t work, we can try a few other things, but i would start there.

finally, compas_ags (among other packages) will be used for teaching “Computational Structural Design 1” in the fall semester at ETH. compas_ags will then also have an installable Python CommandPlugin for Rhino with a UI toolbar and menu. most of the material will be made available online in a similar style as the RV2 docs and workshops…

https://blockresearchgroup.gitbook.io/rv2/
https://blockresearchgroup.gitbook.io/digitalfutures-2020/

tom

Thanks for all the tips, Tom, and for the update on what’s happening with compas right now.

For some reason, everything worked today in GH, without me changing anything yet. I might have missed the need to restart my computer last time… I will make a new environment though.

ha okay, even better :slight_smile:
don’t forget to “re-install” COMPAS for Rhino when you have a new environment. otherwise Rhino will keep connecting RPC to the old one…

Coulda sworn it worked for a bit. But no.

I set up a new environment per your instructions:

conda create -n summum python=3.7
conda activate summum
conda install -c conda-forge COMPAS
python -m compas_rhino.uninstall -v 6.0
python -m compas_rhino.install -v 6.0

In an Anaconda Prompt, it works with the Proxy:

from compas.rpc import Proxy
p = Proxy(‘compas.numerical’)
p.stop_server()
p.start_server()
loads = {‘0-50’: [1, 0], ‘0-100’: [1, 0], ‘0-150’: [1, 0], ‘0-200’: [1, 0]}
supports = {‘0-0’: [1, 1], ‘50-0’: [1, 1], ‘100-0’: [1, 1]}
x = p.topop_numpy(100, 200, loads, supports, volfrac=0.3)
x

Same code in GHPython gives me an error similar to before:

Runtime error (Exception): Traceback (most recent call last):
File “C:\Anaconda3\envs\summum\lib\site-packages\compas\rpc\dispatcher.py”, line 89, in dispatch
module = importlib.import_module(modulename)
File "C:\Anaconda3\envs\summum\lib\importlib_init
.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File “”, line 1006, in _gcd_import
File “”, line 983, in find_and_load
File “”, line 967, in find_and_load_unlocked
File “”, line 677, in load_unlocked
File “”, line 728, in exec_module
File “”, line 219, in call_with_frames_removed
File "C:\Anaconda3\envs\summum\lib\site-packages\compas\numerical_init
.py", line 96, in
from .linalg import * # noqa: F401 F403
File “C:\Anaconda3\envs\summum\lib\site-packages\compas\numerical\linalg.py”, line 28, in
from scipy.sparse.linalg import factorized
File "C:\Anaconda3\envs\summum\lib\site-packages\scipy\sparse\linalg_init
.py", line 114, in
from .eigen import *
File "C:\Anaconda3\envs\summum\lib\site-packages\scipy\sparse\linalg\eigen_init
.py", line 9, in
from .arpack import *
File "C:\Anaconda3\envs\summum\lib\site-packages\scipy\sparse\linalg\eigen\arpack_init
.py", line 20, in
from .arpack import *
File “C:\Anaconda3\envs\summum\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py”, line 43, in
from . import _arpack
ImportError: DLL load failed: The specified procedure could not be found.
Traceback:
line 332, in _proxy, “C:\Users\Summum 01\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\compas\rpc\proxy.py”
line 7, in script

The compas version I’m now using is 0.16.2.

does the script work in Rhino with the proxy?

it looks like a problem related to the Numpy/Scipy installation of your environment. i have seen this before with (extremely recent versions of) Numpy/Scipy on Windows. for whatever reason the underlying DLLs don’t always get loaded properly.

  • can you print the version of numpy and scipy in the prompt?

and just to make sure

  • do you by any chance have another version of Python installed on your system?
  • conda should also not be registered on the PATH. that is the default setting during the installation process, but perhaps check anyway…

depending on the current version of your Numpy/Scipy installation you may want to downgrade to a lower minor version. for example, if you have 1.19.x and 1.5.x which are the most recent versions, perhaps do

conda activate summum
conda install numpy=1.18.3
conda install scipy=1.4.1

don’t forget to include a RPC start/stop or restart in the scripts after you do this. otherwise it will still be running whatever you had running before…

I had Numpy version, 1.19.1 and Scipy version 1.5.2. I downgraded to Numpy 1.18.5 (1.18.3 was not available from “conda search numpy”, only 1.18.1 and 1.18.5) and Scipy 1.4.1.

The script does not work in Rhino Python Editor, or in a GHPython component. The error remains as posted earlier.

I did have an Anaconda Python 2.7 installation which I removed. I currently have an Anaconda Python 3.8 installation. Other than that, I have Code Aster installed, which comes with its own Python 2.7 within it program folders (much like Abaqus for example), but would that actually cause problems? I also had this weird thing, which I resolved, but didn’t cause the error either.

When I type in “where python” in Anaconda prompt, there’s just the one Python installation. I removed Anaconda folders from the Windows’ environment variable PATH, both for the system and the specific user. When I type “path” in a regular Command prompt, it still shows “C:\Anaconda3\condabin” in PATH. Is that the issue?

By the way, this simpler script using rpc, numpy and scipy works fine in Rhino/GH:

from compas.rpc import Proxy
linalg = Proxy(‘scipy.linalg’)
np = Proxy(‘numpy’)
A = np.array([[3,1], [1,2]])
b = np.array([9,8])
x = linalg.solve(A, b)
print x

yes, it seems specifically related to the sparse part of Scipy linalg.

about the condabin, i can indeed confirm that i have absolutely no trace of Anaconda on my PATH variable. so i would remove it.

after cleaning up the PATH it is probably best to restart. (Code Aster and co should indeed not be a problem)