Closed 16239014 closed 3 months ago
How did you installed YARP? Is this working if you run it outside of spyder?
@traversaro i installed yarp with conda forge (robotology superbuild). outside spider when I do python -c "import yarp" it just go to next line and I think its fine. so now when I use yarp in spyder It shows that yarp is imported but no attribute name as Network.
code:
import yarp if hasattr(yarp, 'Network'): yarp.Network.init()
Error log:
runfile('/home/sohail/Desktop/python folder for thesis/import yarp.py', wdir='/home/sohail/Desktop/python folder for thesis') Traceback (most recent call last):
File ~/anaconda3/envs/robsub/lib/python3.11/site-packages/spyder_kernels/py3compat.py:356 in compat_exec exec(code, globals, locals)
File ~/Desktop/python folder for thesis/import yarp.py:1 from yarp import network
ImportError: cannot import name 'network' from 'yarp' (/home/sohail/anaconda3/envs/robsub/lib/python3.11/site-packages/yarp/init.py)
Sorry, it is still not clear to me if yarp.Network.init()
works outside of spyder, by just launching the python
interpreter and running the import yarp
and yarp.Network.init()
code there. Furthermore, can you also report the conda list
in the environment you are using.
Furthermore, you reported that yarp is installed via the robotology-superbuild, but in that case the init.py
should be in /directory/where/you/installed/the/robotology-superbuild/build/install/lib/python3.11/site-packages/yarp/init.py
, while your error report /home/sohail/anaconda3/envs/robsub/lib/python3.11/site-packages/yarp/init.py
. This suggests you have a unclean setup. Can you try to install yarp (either via binaries or sources via the robotology-superbuild, but not both) in a new clean environment/system?
I am running an example from https://robotology.github.io/robotology-documentation/doc/html/icub_python_basic_motor.html and when I try to initialize a Yarp network it shows an error.
Code: import yarp yarp.Network.init()
ERROR LOG IN SPYDER: