Skip to content

Common issues

m-giraud edited this page Oct 12, 2024 · 21 revisions

Module not found error

Description of the issue:

  • The program compiled successfully
  • When trying to launch a python file, the message "ModuleNotFoundError: No module named 'plantbox'" was received.

Option 1

The program compiled for a different python version than the one used to launch the python file. To test:

  • Get the python version currently used by running python3 --version in the linux command line.
  • Go to the CPlantBox root folder. You will find two files with the extension ".so". One of them has a name similar to "plantbox.cpython-YYY-x86_64-linux-gnu.so" . Instead of YYY, you will have the version of python for which CPlantBox was built.
  • If YYY does not correspond to the python version currently used, this might be causing the error. Solutions: Two solutions are possible:
  1. Delete the "CPlantBox/CMakeFiles" folder, the CMakeCache.txt file and the two .so files. Then re-compile the CPlantBox program. The compiler should use automatically the python version currently used.
  2. Create and activate a conda environment where the default python version is the one for which CPlantBox was built.

Option 2

The python software cannot find the plantbox.cpython-YYY-x86_64-linux-gnu.so file To test:

  • go to the folder where the plantbox.cpython-YYY-x86_64-linux-gnu.so is located
  • launch python by sending python3 in the linux command line
  • try to import plantbox by entering import plantbox in the python environment
  • If the plantbox package is imported without error, it could be that the search paths in the other python file are wrong

Solution:

Add/adapt the python search path in the relevant python file by adding:

import sys

sys.path.append("relative path between the current working directory and the location of the .so file")

The working directory of the program when launching the python file might not be the file location. Check the working directory by running:

import os

print(os.getcwd()) #current working directory

Definition of the lateral growth delay

The growth delay of the laterals is represented according to the value of the seed parameter DelayDefinition parameter (either 0, 1, or 2):

  1. according to the growth rate (r) and the apical distance (la) of the parent organ
  2. from the growth delay value (ldelay) of the parrent organ
  3. from the growth delay value (ldelay) of the lateral

The CPlantBox repository is too big/heavy

Currently the CPlantBox repository is quite heavy, in part because of the history. We will remove unwanted history. in the mean time, you can use git clone --single-branch --depth=1 -b [branch] https://github.com/Plant-Root-Soil-Interactions-Modelling/CPlantBox.git to have lighter repo locally. it s the cloning method currently implemented in the python install files.

I want to switch the CPlantBox branch

if you want to switch to the <remote_branch_name> branch after the first CPlantBox installation, use:

git remote set-branches origin <remote_branch_name>
git fetch -v --depth=1
git stash
git checkout -b <new_local_branch_name> origin/<remote_branch_name>
git branch -a # check that you are on <new_local_branch_name>
git submodule update --recursive --init
cmake .
make

I cannot push my branch to the remote repository

If you have installed CPlantBox via the python install scripts, the remote repository is saved by git is formated as "https://[...]", which does not allow you to push your branch. You can check if that is the case by running in the CPlantBox root folder:

git remote -v

If you get:

https://github.com/Plant-Root-Soil-Interactions-Modelling/CPlantBox.git

you need to change the format.
Run:

git remote set-url origin [email protected]:Plant-Root-Soil-Interactions-Modelling/CPlantBox.git

You should now be able to push.

Issues with the OpenGL

If, after using the python install scripts, you get the error message
vtkXOpenGLRenderWindow (0x55b2f1b0cbb0): Cannot create GLX context. Aborting.
when running some of the CPlantBox examples, try the following commands:

sudo apt-get update 
sudo apt-get upgrade
sudo apt install mesa-utils libglu1-mesa-dev freeglut3-dev mesa-common-dev 
export DISPLAY=:0 
export LIBGL_ALWAYS_INDIRECT=0

to avoid having to run

export DISPLAY=:0 
export LIBGL_ALWAYS_INDIRECT=0

For each new WSL session, you can add these commands at the end of either the "/etc/bash.bashrc" or "~/.bashrc" file.

Wrong default backend for matplotlib

If, when using matplotlib.pyplot (e.g., plt.show(1,1)), you get the following error message:

Failed to create wl_display (No such file or directory)
qt.qpa.plugin: Could not load the Qt platform plugin "wayland" in "" even though it was found.

It is necessary to change the default backend for matplotlib to tk:

touch ~/.config/matplotlib/matplotlibrc # creates the files if it does not exist
echo "backend: TkAgg" >> ~/.config/matplotlib/matplotlibrc ## append to the file