Can't run Mathematica on Raspberry Pi under php

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

Since Mathematica is contained in Raspberry Pi 2, I can do the following in the terminal:

echo "2+2" | /usr/local/bin/math -batchinput -batchoutput

It outputs 4 correctly. But when I try it with php:

php
$math="echo '2+2' | /usr/local/bin/math -batchinput -batchoutput";
$handle = popen($math, "r");
$str=fread($handle,200);
echo $str;
?>

It says that

Mathematica cannot find a valid password.

I find the license for Mathematica, in

/opt/Wolfram/WolframEngine/10.0/Configuration/Licensing/mathpass

Does this mean that Mathematica needs another license for interface with php?

UPDATE

I have solved this by adding an active key and password for the user www-data, which will stored in /var/www/.WolframEngine/Licensing/mathpass.

profilepic.png
manpreet 2 years ago

 

Mathematica on the Raspberry Pi already comes with a license preinstalled, however running it as a user with insufficient access privileges may result in a prompt for activation or a password.

Here is a slightly more detailed explanation of what is happening, which is also discussed on Wolfram Community.

Early in the kernel (or FrontEnd) startup, as part of a series of hardware checks, Mathematica needs to talk to the Broadcom VideoCore chip. The default permissions for device should be similar to

crw-rw---- 1 root video 250, 0 Oct 27 22:17 /dev/vchiq

For example, if the user is not a member of the video group, opening the device will fail, resulting in a different $MachineID which no longer matches the preinstalled password. Hence, the product will not be activated.

A good way to resolve this issue is to check the device permissions are as above, and add the non-privileged user to the video group

sudo usermod -a -G video www-data

I have solved this by adding an active key and password for the user www-data

Yes, this will also work, but is more expensive: it requires the Pi owner (or his organization) to have purchased a Mathematica license. That is not necessary on the Raspberry Pi.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.