I sometimes get the following error message :
“Error Importing Numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there.”
The only resolution I’ve found so far is to manually remove all numpy related files from the .rhinocode directory. They are then reinstalled with the “# r:” method the next time I run the script.
Then, everything works for a few days, and then the message reappears.
The error occurs both in GH and in ScriptEditor
To call this issue aggravating is an understatement.
Is there a fix I don’t know about?
Is there any reason this should happen spontaneously?
As @nathanletwory responded above, pip package name for tensorflow is tensorflow lowercase. So if you are using the Install Package window make sure to type tensorflow and not TensorFlow
hi @eirannejad all library install successfully but after restart Rhino get new error for numpy ?1. Error running script: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there. [2:1] But adding this line to the script fixed the error
I believe turtle is included in the Rhino distribution (it is in my py39-rh8\lib folder) and all you need is an import turtle as tu statement.
It looks like there will be some thrashing out needed to manage the Python Turtle Graphics window’s destruction elegantly. And I find turtle can crash grasshopper. But then I don’t know what I’m doing with it.
You can simplify your script. Firstly, you only need one # venv: statement. Secondly # requirements: is a synonym for # r:, so you don’t need both tensorflow statements. Try this:
ghenv.Component.Message = "library python"
ghenv.Component.NickName= "library python"
ghenv.Component.Name = "library python"
"""Grasshopper Script"""
# venv: site-packages
# r: sympy
# r: tensorflow
# r: luminoth
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import Grasshopper as gr
import sympy as s
import numpy as nu
import tensorflow as te
import turtle as tu
import bob as bo
import matplotlib as mt
#import luminoth as lm
import ghpythonlib as gh
import Rhino as r
import pendulum as pmmm
b=pmmm.day.annotations
a = "Hello Python 3 in Grasshopper!"
a=nu.cos(nu.deg2rad(60));
a=s.acos(0)
a=te.sin(3.14)
print(a)