yarp icon indicating copy to clipboard operation
yarp copied to clipboard

Error: Module not found YARP when i try to use it using python 3.11

Open 16239014 opened this issue 1 year ago • 21 comments

I will describe what i did from start:

1. I did source install in robsub envoirment unsing Conda forge. steps i follow (https://github.com/robotology/robotology-superbuild/blob/master/doc/conda-forge.md#binary-installation)

2. Then i install this example in same robsub (https://icub-tech-iit.github.io/documentation/sw_installation/check_your_installation/#check-icub) i run on gazebo.

3. Then in last i install python 3.11.7 and using spyder 5.5.4 in robsub and try to run this code https://robotology.github.io/robotology-documentation/doc/html/icub_python_basic_motor.html

ERROR LOG:

runfile('/home/sohail/Desktop/python folder for thesis/untitled0.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/untitled0.py:2
    import yarp

ModuleNotFoundError: No module named 'yarp' 

16239014 avatar Jun 03 '24 09:06 16239014

If you type python -c "import yarp" from the command line in which the robsub environment is activated and in which you sourced the setup.sh script of the robotology-superbuild what happens? If that works, the problem is probably spyder-specific and it may be more useful to ask support in spyder-related channels.

traversaro avatar Jun 03 '24 19:06 traversaro

i did what you told python -c "import yarp" but i get same error no module name yarp

you can see step i follow maybe i did something wrong

Error log:

(base) sohail@sohail-Lenovo-V14-G3-IAP:~$ conda activate robsub
(robsub) sohail@sohail-Lenovo-V14-G3-IAP:~$ source /home/sohail/robotology-superbuild/build/install/share/robotology-superbuild/setup.sh
(robsub) sohail@sohail-Lenovo-V14-G3-IAP:~$ python -c "import yarp"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'yarp'

16239014 avatar Jun 04 '24 04:06 16239014

Thanks, can you report the content of PYTHONPATH env variable after you call source /home/sohail/robotology-superbuild/build/install/share/robotology-superbuild/setup.sh, i.e. :

echo $PYTHONPATH

Are you sure that you enabled the ROBOTOLOGY_USES_PYTHON=ON CMake option of the robotology-superbuild?

traversaro avatar Jun 04 '24 04:06 traversaro

content of pyhtonpath:

(robsub) sohail@sohail-Lenovo-V14-G3-IAP:~$ echo $PYTHONPATH
/home/sohail/robotology-superbuild/build/install/lib/python3.11/site-packages

Are you sure that you enabled the ROBOTOLOGY_USES_PYTHON=ON CMake option of the robotology-superbuild?

Yes i enable this

16239014 avatar Jun 04 '24 04:06 16239014

Can you check the content of /home/sohail/robotology-superbuild/build/install/lib/python3.11/site-packages and of /home/sohail/robotology-superbuild/build/install/lib/python3.11/dist-packages ?

traversaro avatar Jun 04 '24 04:06 traversaro

Can you check the content of /home/sohail/robotology-superbuild/build/install/lib/python3.11/site-packages and of /home/sohail/robotology-superbuild/build/install/lib/python3.11/dist-packages ?

there no folder in lib named as python3.11.

16239014 avatar Jun 04 '24 04:06 16239014

Interesting, can you report the /home/sohail/robotology-superbuild/build/src/YARP/install_manifest.txt and /home/sohail/robotology-superbuild/build/src/YARP/CMakeCache.txt files? Thanks!

traversaro avatar Jun 04 '24 12:06 traversaro

Those files you asked for were too large, so I attached them:

Interesting, can you report the /home/sohail/robotology-superbuild/build/src/YARP/install_manifest.txt install_manifest.txt

/home/sohail/robotology-superbuild/build/src/YARP/CMakeCache.txt CMakeCache.txt

16239014 avatar Jun 05 '24 04:06 16239014

Did you enable the ROBOTOLOGY_USES_PYTHON superbuild CMake option?

traversaro avatar Jun 05 '24 13:06 traversaro

Did you enable the ROBOTOLOGY_USES_PYTHON superbuild CMake option?

Screenshot from 2024-06-05 21-01-24

16239014 avatar Jun 05 '24 16:06 16239014

That is quite strange, in YARP's CMakeCache.txt you have CREATE_PYTHON:INTERNAL=OFF, but that variable should be set to ON by robotology-superbuild. Can you run make YARP in the build of the superbuild and try again? Something really strange is happening.

traversaro avatar Jun 05 '24 17:06 traversaro

@traversaro After runmakein build of superbuild i found python3.11 folder in lib. I know you asked for make yarp

Output:

(robsub) sohail@sohail-Lenovo-V14-G3-IAP:~/robotology-superbuild/build$ make yarp
make: *** No rule to make target 'yarp'.  Stop.

can you report the /home/sohail/robotology-superbuild/build/src/YARP/install_manifest.txt and /home/sohail/robotology-superbuild/build/src/YARP/CMakeCache.txt files?

I DONT KNOW HOW TO REPORT IT SO ATTACH SCREENSHOT Screenshot from 2024-06-06 01-42-12

16239014 avatar Jun 05 '24 20:06 16239014

@traversaro i think you forgot to reply??

16239014 avatar Jun 14 '24 13:06 16239014

Sorry, I asked to run make YARP, not make yarp, can you try and report the output?

traversaro avatar Jun 14 '24 14:06 traversaro

Sorry, I asked to run make YARP, not make yarp, can you try and report the output?

sorry for late response, Build target YARP 100% but still error in spyder occur: module not found error : no module named 'yarp'

16239014 avatar Jun 23 '24 09:06 16239014

Ok, can you please report the CMakeCache.txt and install_manifest.txt after you run make YARP . python -c "import yarp" still fails? Let's try to fix this before trying to get it to work in spyder

traversaro avatar Jun 23 '24 14:06 traversaro

Ok, can you please report the CMakeCache.txt and install_manifest.txt after you run make YARP Files Are: CMakeCache.txt install_manifest.txt

python -c "import yarp" still fails? Let's try to fix this before trying to get it to work in spyder.

  1. First i activated the environment.
  2. then source it
  3. run yarpserver
  4. In new terminal again i activated environment and sourcing then i run the command you said python -c "import yarp it stuck here for more than 30 minutes

Screenshot from 2024-06-24 11-08-27

16239014 avatar Jun 24 '24 06:06 16239014

You need to run python -c "import yarp", not python -c "import yarp.

traversaro avatar Jun 24 '24 06:06 traversaro

You need to run python -c "import yarp", not python -c "import yarp.

With sourcing nothing happen it just go to next line

Without sourcing it show error:

(robsub) sohail@sohail-Lenovo-V14-G3-IAP:~$ python -c "import yarp"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'yarp'

16239014 avatar Jun 24 '24 07:06 16239014

If you do not get any error, it means that yarp is found correctly. I am not sure how to make Spyder use superbuild's yarp.

traversaro avatar Jun 24 '24 07:06 traversaro

Looking on Google, you could:

  • Make sure that you start spyder from the robsub environment and in a terminal in which you sourced the setup.sh of the robotology-superbuild
  • Make sure that spyder is using the python executable of the robsub environment, see https://docs.spyder-ide.org/current/faq.html#using-existing-environment for more details. I guess it should be ~/anaconda3/envs/robsub/bin/python .

traversaro avatar Jun 24 '24 08:06 traversaro