"no module named cvb" bei "import cvb"

Wenn ich den Code aus C:\CVB\Tutorial\Polimago\CvbPy\classification.py geladen und wollte es ausfürhen. Dann kommt die Fehlermeldung:
ModuleNotFoundError: No module named ‘cvb’

Hi,
did you install the python wheely for CvB?
Check these two tutorials in case you have not:
https://forum.commonvisionblox.com/t/getting-started-with-cvbpy/241

https://forum.commonvisionblox.com/t/python-setup-guide-with-anaconda-by-christopher/580

Please note that the pip installation works not only for conda but also for regular python. No need to use conda.

@raphy
errr i have to update my tutorial … installing/downloading the wrapper (separatly) is no longer required.

But the wheely still needs to be installed via pip to be able to load the module in python.

Yes. Step 3 in my tutorial is no longer required. Somehow i can’t edit the topic.

Hey Everyone,

I got stuck in a very wired situation. I know this is problem with pythonpath and required some linux expertise but I would be thankful if anyone could help me.

So, I am trying to perform image acquisition on Nvidia agx on startup. Normally, If ran the python script from terminal it works fine, you can see the system path that cvb is located and the image acquisition is working perfectly:

import sys
print(str(sys.path))
['/home/agx/Documents/CVBDATA', '/home/agx/catkin_ws/devel/lib/python2.7/dist-packages', '/opt/ros/melodic/lib/python2.7/dist-packages', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/agx/.local/lib/python3.6/site-packages', '/home/agx/.local/lib/python3.6/site-packages/cvb', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.6/dist-packages', '/home/agx/.local/lib/python3.6/site-packages/cvb']

As you can see, cvb is located in the system path, similar is also for python3.6.

However, when I tried to run this python script from bash terminal on system boot going through systemd service and all the long process) I am getting the error, this is the piece of command that I am using to invoke the python script:

nohup python3 /usr/local/bin/final.py &

Error:

Traceback (most recent call last):
Feb 10 11:26:11 agx lidarCameraData_acquisition.sh[18925]:   File "/usr/local/bin/final.py", line 7, in <module>
Feb 10 11:26:11 agx lidarCameraData_acquisition.sh[18925]:     import cvb
Feb 10 11:26:11 agx lidarCameraData_acquisition.sh[18925]: ModuleNotFoundError: No module named 'cvb'

This is the system path for above (I logged it during the script execution), you can see the cvb is there but still it complains, you can see the above error logs:

['/home/agx/Documents/CVBDATA', '/home/agx/catkin_ws/devel/lib/python2.7/dist-packages', '/opt/ros/melodic/lib/python2.7/dist-packages', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/agx/.local/lib/python3.6/site-packages', '/home/agx/.local/lib/python3.6/site-packages/cvb', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.6/dist-packages', '/home/agx/.local/lib/python3.6/site-packages/cvb']

Even I tried with -m option but no success. Nevertheless, I am getting the following errors

/usr/bin/python3: No module named /usr/local/bin/final

/usr/bin/python3: Error while finding module specification for '/usr/local/bin/final.py' (ModuleNotFoundError: No module named '/usr/local/bin/final

Any help would be appreciated,

Regards,
Aftab

Hey, I was able to find the culprit, the CVB is installed for local user agx and not for root the cvb (root is running the process so it make sense that it should in the path).

I became root and tryied to run:

python3 -c 'import cvb'

and was getting the same error.

Now I want to ask a small question, how can I change the current installation that cvb is visible to all users on the system.

Regards,
Aftab

Hi @aftab,

  1. The installation of CVB is always available for all users. See /opt/cvb/. The required env vars are exposed to each user (but not root).
  2. What you actually want is to install the python package as root (i.e. sudo python3 -m pip install <.whl>). Then it should be available to all users (mind the python path again). You may have to uninstall the whl first.
1 Like

Is “root” a proper user?

Hey,

Thank you @c.hartmann .

Yes, the root is a proper user.

I tried to add /home/agx/.local/lib/python3.6/site-packages to the path using

import sys
sys.path.append(......)

But no I am getting this error now CVB Environment variable not set.

Regards,
Aftab

Hi @aftab,

this is what i feared :-), but it’s not hard to fix.

As a normal user type: env | grep -i cvb. Those are the missing env vars.

Should print a list like this:

CVB=/opt/cvb
GENICAM_GENTL64_PATH=/opt/cvb/drivers/genicam
CVGENICAM_REGISTRY=/var/opt/cvb/Registry
GENICAM_CACHE_V3_1=/var/opt/cvb/genicam
CVBDATA=/var/opt/cvb
CVBCONFIG=/etc/opt/cvb

Essentially the root user must have these as well (either via export before calling python or some other way).

1 Like

Hey @c.hartmann,

Thank you so much. I tried to add the env and export it that you have mentioned to the bashrc of the root but I am still getting the same erro CVB Environment variable not set.

Any idea why its happening and what would you recommend?? either to remove cvb and install with sudo. Normally if I become a root and try to run in the terminal I am not getting this error.

Regards,
Aftab

No the cvb enviroment variable not set affect the cvb installation, not the installation of the cvb python module.

1 Like

if you login as “root” and type “env | grep -i cvb” what is your output.

1 Like

Hey @c.hartmann

I get the following output:

CVB=/opt/cvb
GENICAM_GENTL64_PATH=/opt/cvb/drivers/genicam
CVGENICAM_REGISTRY=/var/opt/cvb/Registry
GENICAM_CACHE_V3_1=/var/opt/cvb/genicam
CVBDATA=/var/opt/cvb
CVBCONFIG=/etc/opt/cvb

I think I have to give up nohup. Without nohup it is working but I have to source the /root/.bashrc.

Hi @aftab ,

Are you using virtual environments?
You may try to start from uninstalling CVB via the “uninstall_cvb.sh” from the zipped installer folder. Also remove cvb wheel by executing python3 -m pip uninstall cvb.
Verify, that there is no such folder or file starting with “cvb” inside the directories containing “site-packages” or “dist-packages”, listed when executing python3 -m site! If this is the case, delete everything reminding you of cvb.

Then start off from scratch and execute all the steps with the same user:

  1. Install CVB via the provided script (install_cvb.sh).
  2. Verify, that afterwards the variables @c.hartmann mentioned are set, if not, do so.
  3. Go to $CVB/python
  4. Execute (without sudo) python3 -m pip install cvb*.whl
  5. Look into the folders (either conaining “site-package” or “dist-packages” listed when executing python3 -m site
  6. If you cannot find any folder or file with “cvb” in the name go to X)
  7. Check python3 -c "import cvb"

X) Please collect some setup information:

  • platform, architecture, OS version
  • CVB release
  • python release
  • a short introduction into your task

Send that information to this adress with a short reference to this thread.

2 Likes

Hey @s-woe,

Thank you so much for your time. I will follow your instruction and get back to you.

Regards,
affi