Open Mamooshe opened 9 months ago
sudo pip install pypylon
sudo pip install pypylon
I tested it but still doesn't know pypylon library in root. If I use : sudo su python3 import pypylon
gives me error of not recognizes pypylon
but without sudo su everything is ok and because my program is crontab, it must be executed in root
Calling a user process from a crontab
in Unix-like operating systems involves scheduling a command or script to run at specified times or intervals. Here's a general guide on how to do this:
First, you need to open the crontab file for editing. You can do this for the current user by running the following command in the terminal:
crontab -e
If you need to edit the crontab for another user (assuming you have the necessary permissions), you can use:
sudo crontab -u username -e
In the crontab file, you can add a new line that specifies when and what command you want to execute. The syntax for a cron job is:
* * * * * command-to-execute
The asterisks represent different units of time:
For example, to run a script every day at 5:00 PM, you would use:
0 17 * * * /path/to/your/script.sh
When you schedule tasks with crontab, they are run with the user's environment who owns the crontab. It means that environment variables available in your terminal session might not be available for scripts run by cron. Therefore, it's a good practice to define needed environment variables within your script or explicitly in the crontab.
If your script needs to run as a specific user, make sure that user's crontab is the one being edited, or ensure the script switches to the correct user if necessary and possible.
0 17 * * * /path/to/your/script.sh > /path/to/logfile 2>&1
After adding your cron job, save and exit the editor. The crontab service will automatically pick up the changes. You can list the current user's cron jobs with:
crontab -l
This setup should be sufficient for most uses of cron to call user processes. Adjustments may be needed based on specific requirements, such as handling more complex scheduling or environment setups.
Therefore, it's a good practice to define needed environment variables within your script or explicitly in the crontab.
thank you.
as you mentioned
"it's a good practice to define needed environment variables within your script or explicitly in the crontab"
so my environment is root. How can I install pypylon python API in root?
by using pip install pypylon it's not installed in root.
The hint with crontab above was, that you can enable running crontab as your user account.
As I don't know what your OS version, python version and username is, here some examples
If you install pypylon as a user jetson. On e.g. Ubuntu 18.04 the install will be in
/home/jetson/.local/lib/python3.6/site-packages
the python interpreter will find this, as this is the std location for users.
you could reference this also from your root crontab by setting
PYTHONPATH=/home/jetson/.local/lib/python3.6/site-packages/
in the root environment.
Alternative would be a system install using
sudo su
pip3 install pip --upgrade
pip3 install pypylon
then on ubuntu 18.04 the install will end up in /usr/local/lib/python3.6/dist-packages/
Is your issue solved?
pypylon is not recognized in os root in jetson:
by using pip install pypylon, the root doesn't recognize pypylon library in nvidia jetson board. I need camea grabbing to be executred in autorun and for autorun access to root is required. so all libraries should be defind in root. How can I install basler library in root?
Reproduce the code example:
Error message:
Is your camera operational in Basler pylon viewer on your platform
Yes
Hardware setup & camera model(s) used
Nvidia jetson nano
Runtime information: