GHPython Remote error

Hi,

I have trouble with GHPython Remote :slightly_frowning_face:

I have followed these instructions:
https://wiki.mcneel.com/grasshopper/cpython
and also
http://theonovak.com/news_2_ghpr_guide.html

These instructions seems to work just fine with other computer that i have, but with this computer, which i am using right now i get this error:

Runtime error (Exception): CalledProcessError

Traceback:
line 229, in check_output, “C:\Program Files\Rhino 6\Plug-ins\IronPython\Lib\subprocess.py”
line 58, in get_python_from_conda_env, “C:\Users%UserName%\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\ghpythonremote\helpers.py”

line 28, in get_python_path, “C:\Users%UserName%\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\ghpythonremote\helpers.py”

line 20, in init, “C:\Users%UserName%\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\ghpythonremote\connectors.py”
line 49, in script

I have reinstalled and gone through instructions multiple times and I have no glue what i should do right now.

I am using Rhino 6

pip list:

env list:

(rhinoremote) C:\Users%UserName%>conda env list

conda environments:

base C:\Users%UserName%\Anaconda2
rhinoremote * C:\Users%UserName%\Anaconda2\envs\rhinoremote

its looks like this:

Hello,

Have you tried these instructions?

I haven’t tried this…

Not sure what the issue is here, sorry. Could you tell me what versions you have installed, by running the following commands?

In the Windows cmd:

conda activate rhinoremote
conda -V
python -V
pip show rpyc
pip show gh-python-remote

In a Rhino Python script:

import rpyc, ghpythonremote, sys, os
from ghpythonremote import version as ghpyrv

print(sys.version)
print(sys.path)
print(rpyc.__version__)
print(rpyc.__path__)
print(ghpyrv.__version__)
print(ghpythonremote.__path__)

Hi,

I too am having the same issue as Jaakko, and am getting the exact same returns in the panel connected to the ‘out’ of the GH python remote. I tried reinstalling Rhino6 and everything.

If I run the commands I get the following outputs for the versions I am running, ofc in the order you listed above.

  • conda 4.7.10
  • Python 2.7.16 :: Anaconda, Inc.
  • Version: 4.1.2
  • Version: 1.2.1

When I run your code in a Rhino Python I get the following output

moduleRhinoPythonOutput

The error above seems to be in the code trying to parse your conda envs to find the path to the python exe that is specified by the conda://rhinoremote location. Could you change that to C:\Users\<username>\.conda\envs\rhinoremote\python.exe as a workaround?

I’ll look into the real bug as soon as I can.

Hi,
Thank you for your fast reply,

It seems that your suggestion worked in part, as several error codes have been solved. The problem now seems to be that it cannot find rpyc, despite it showing up in my rhinoremote pip list.

When searching through the specified code in the error message (connectors.py), it appears to have something to do with connection.

  • Are you absolutely certain that the command C:\Users\<username>\.conda\envs\rhinoremote\python.exe -m pip show rpyc returns the expected RPyC information? The best is to run it in cmd.exe, not in the conda shell.
  • Do you see a console window popping up when you turn on GHPyRemote?

Yes, when I run that command through my command prompt the following is returned which, as I assume, the expected information.

When I turn on GHPyRemote the console window pops up for a fraction of a second.

There is something going on here that I don’t understand… I’ll have to look at this in a debugger, but it won’t be till next week.

Also for some reason the debug logs are not showing up in your GHPythonRemote output. Do you get more info when you open double-click the GHPythonRemote component to open the Python editor, before switching the toggle to on? You might also need to click on “Test” in the editor at some point.

If you feel like doing more debugging yourself, you can try this:

  1. Open an rpyc server in a command prompt: C:\Users\<username>\.conda\envs\rhinoremote\python.exe "%APPDATA%\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\ghpythonremote\pythonservice.py" 18871 DEBUG
    You should either get an error message, or some debug messages and a prompt that never returns.
  2. If the first step does not return, it means the sever is running and you can try connecting to it from another console: C:\Users\<username>\.conda\envs\rhinoremote\python.exe -c "import rpyc; c = rpyc.classic.connect('localhost', 18871); print(c)"
    The second step should print something like <rpyc.core.protocol.Connection 'conn1' object at 0x0000000003BA47F0>, return, and close the server that was created in the first step.

Hi,

Thank you for your helping so much, in regards to the debug logs, I previously turned off the debug logs to see the errors, but have turned them back on and below a screenshot of the log is show. Also I took the time to uninstall Anaconda completely and reinstall, but it did not seem to change anything.

In regard to your debugging tips (I don’t have much experience myself), but I hope the following screenshot could help you.

I think there is something broken in your RPyC installation. The first error in your second screenshot should definitely not happen in a functioning installation, and I can’t reproduce it here.

Do you maybe have a directory called rpyc somewhere in your home folder, or in the Python path? You can get your python path by running python -c "import sys; print(sys.path)" in a prompt with env rhinoremote activated. The only directory containing a rpyc item should be the last one, ending in site-packages.

Since you reinstalled Conda, I guess that you also went through the installation procedure again for GHPythonRemote and your RPyC installation has not been modified. Still, I’d like to see if the installation logs for RPyC tell us anything. Try a reinstall with these commands, and report if you see any error:

conda activate rhinoremote
pip uninstall -y rpyc
pip install rpyc

A good way to check if that did anything is to run that debugging command “1.” from my previous message. If you are still in a prompt with rhinoremote activated, you can skip the path to python and run: python "%APPDATA%\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\ghpythonremote\pythonservice.py" 18871 DEBUG

If that still returns the same error as before, please report the output of:

conda activate rhinoremote
python -c "import rpyc, ghpythonremote; print(rpyc.__file__); print(ghpythonremote.__file__); print(ghpythonremote.rpyc.__file__)"
python -c "from rpyc import ClassicService; import inspect; print(inspect.getsourcefile(ClassicService))"
python -c "from ghpythonremote import rpyc; import inspect; print(inspect.getsourcefile(rpyc.ClassicService))"
python -c "from ghpythonremote import rpyc; import inspect; print(inspect.getsource(rpyc.core.protocol.Connection._netref_factory))"

Also, that might be related to the initial conda issue you were experiencing at first. What’s the output of conda env list -v?

Hi Pierre,

I have recently revisited installing GH Python remote. I did a complete wipe of all my anaconda files and reinstalled Anaconda3, and followed the guide to installing GHPython Remote. It appears that I have managed to solve all the issues apart from an error within the IronPython plugin within Rhinoceros 6. Within Grasshopper the server connection goes without any issues, but when running the block of python code to the right of this startup block, it returns a ''Runtime error (EndofStreamExeption): Stream has been closed" error. In the screenshot below the traceback is shown, and it appears to once again have to do with the rpyc, but this time the files embedded within Rhino 6.

Furthermore command 1 from your reply from October 9 runs without any issues, I did have to change something in the command; for some reason the .conda folder is empty and all of the rhinoremote information regarding the environment is now stored under “C:\Users<username>\Anaconda3\envs\rhinoremote”. Im not sure if this is of any use to you regarding what is happening.

I also reinstalled rpyc according to your instructions from your last post. Below the list of anaconda environments is shown along with the pip list.

Conda%20env%20list

Lastly I am not sure if this last piece of information is of any value to you, but within a cmd.exe window when inputting “conda activate rhinoremote” it returns a message stating that my shell has not yet been properly configured to use conda activate.

Thank you in advanced for your time,
Jelle

Hey, that’s much further than last time, looks like we almost got a working install here!

Within Grasshopper the server connection goes without any issues, but when running the block of python code to the right of this startup block, it returns a ''Runtime error (EndofStreamExeption): Stream has been closed" error.

Do you mean that you:

  1. Open the example file in %APPDATA%\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\ghpythonremote\examples\GH_python_remote.ghx,
  2. Switch to True the GHPythonRemote component “run” input, then
  3. Check that the last line in the GHPythonRemoteComponent “out” ouput is INFO: ghpythonremote.GH_to_python: GH to python connection is OPEN, then
  4. With the GHPythonRemote component “run” input still True,
  5. Double click the Python component on the right, click “OK” in the editor that opens, and
  6. Get the output in your screenshot as a result?

Did you modify anything in the example file? Is there anything else in the “out” of the GHPythonRemote component?

Here is what it should look like by that point:

Hi Pierre

If I get the result you showed in the last post, does that mean that GHPython Remote is running as it is supposed to? To be fair, I did have to use the workaround for the location (C:\Users<username>.conda\envs\rhinoremote\python.exe), but I don’t expect this to be an issue?

Thanks for your excellent work.
I wonder whether this is something that will be built in in the next version of Grasshopper or Rhino.

Yes! Glad we got this working.

I’ll keep on lobbying for a CPython 3 interpreter in Rhino, that would be a much better solution than forcing that plugin to every installation of GH (I don’t think everyone wants a conda installation on their computer when they install GH :).

2 Likes

I wonder whether the new windows store version of python could be a route to better integration with Rhino/ GH :thinking: :snake:

I thought everything was fine, but unfortunately scipy does not want to participate somehow. I was trying an integral first as a test.

Runtime error (Exception): ‘module’ object has no attribute ‘integrate’

Scipy is installed, imported and linked as a module, so I wonder what else could be causing this.

The examples using numpy do work as a charm as shown in the image.

You need one import name per submodule you want to use, and it’s a good idea to import the higher-level modules first.

So in the modules input to GHPythonRemote, add scipy.integrate at the bottom of the list and you should be good to go. To use integrate in your GHPython scripts, you will need something like integrate = scriptcontext.sticky['scipy.integrate'].

1 Like

Thank you for the nice application, I tried the GH_python_remote file and it worked!

However, when I edited the example Python script to make some figures, I got the following error message:

I only added 5 lines at the bottom (and added matploblib and matplob.pyplot in the modules list):

Maybe good to know that when removing these ‘plot’ lines and testing the code again, the error does not disappear. It removes only when restarting the GHpythonremote component.

I do have matplotlib installed, as I am able to make plots from any other Python editor.

Anybody experiences this problem as well and has an idea about how to fix this?

Best,
Maartje