MATLAB MCC "??? Error Using ==> mcc, return status = 1" - linux

I'm trying to compile a matlab .m file on a linux cluster using mcc. R2008b is installed on the cluster.
I am using http://www.it.northwestern.edu/research/sscc/matlabcompiler.html as a guide.
My plusone.m file is as follows:
function y = plusone(x)
if(ischar(x)), x = str2num(x), end;
y = x + 1;
I am running matlab on the cluster using the command "matlab -nodisplay".
I have run mbuild -setup and have added (my matlab root folder)/bin and /sbin to $PATH.
I am using the command mcc -m -v plusone.m from within MATLAB, and the full output is:
"??? Error using ==> mcc Error executing mcc, return status = 1."
This output is the same for a few different .m files and a number of different flag settings.
Without more error information, I'm a bit stumped. Suggestions about what might be causing the error or ways of getting more information about the error would be greatly appreciated.

Related

How to check if the environment variable "PROJ_LIB" is defined and how to unset it ? (PyQGIS Standalone Script Executer)

I just tried the standalone PyQGIS application by running the custom script "Proximity.py"* in a VS Code project without the need of a GUI (such as QGIS).
But, when I run the python-program I get the following message:
proj_create_from_database: C:\Program Files\PostgreSQL\14\share\contrib\postgis-3.2\proj\proj.db contains DATABASE.LAYOUT.VERSION.MINOR = 0 whereas a number >= 2 is expected. It comes from another PROJ installation. (see also: Error Message after launching the configuration (launch.json) from VS Code (when pressing F5))
I'm trying this online example with the following installations:
PostgreSQL 14
Python39
.vscode\extensions\ms-python.python-2022.4.1\pythonFiles\lib\python\debugpy\launcher
osgeo4w-setup.exe (including QGIS LTR)
I read that there is a solution by undefining [PROJ_LIB] before importing pyproj or osgeo: del os.environ ['PROJ_LIB'] as described under this link. If this is also supposed to be the correct solution in this case, can someone help me with step-by-step instructions (for dummies)?
. * The "Proximity.py" script is a pyqgis standalone example from "https://github.com/MarByteBeep/pyqgis-standalone"
Finally, I got a solution to be able to run the "standalone PyQGIS"* example "Proximity" (provided by MarByteBeep).
This solution was possible without needing to launch the configuration file "launch.json" as above described. And so, avoiding the need to make any configuration to the environment variable "PROJ_LIB" by trying to circumvent the above issue.
I just first added the following two code-lines (see here line 2 and 3) in the python file "main.py" so as to be able to use the plugin "PROCESSING" (initially line 8 of the "main.py" file), then I store it and finally I ran it.
Line 1: from qgis.core import
Line 2: import sys
Line 3: sys.path.append('C:\Program Files\QGIS 3.24.1\apps\qgis\python\plugins')
Line 4: qgs = QgsApplication([], False)
Line 5: ...
The Proximity example is based on the answer of "Mar Tjin" to the following Question: "Looking for manual on how to properly setup standalone PyQGIS without GUI"
. * By "Standalone PyQGIS" I refer to code/scripts that can be run outside the QGIS-GUI (=> QGIS-Desktop/Server Application). In my case under the external Editor VS Code

Execute Python script using Laravel?

I'm trying to execute a python script in a Laravel 5.8 project but I'm having problems with the Symfony/process class.
Basically, I want to run this python script that takes an excel form from the storage folder.
My first try was this
$process = new Process('C:\Python\python.exe C:\Users\"my path"\laravel\storage\app\images\cargaExcel.py');
$process->run();
if (!$process->isSuccessful()) {
throw new ProcessFailedException($process);
}
echo $process->getOutput();
And the error is
Fatal Python error: _Py_HashRandomization_Init: failed to get random numbers to initialize Python
I also tried with shell_exec(), and if the two files (the excel and the python script are in the public path - app/public) it works.
I think the problem is that python only executes on the app/public folder, so I don't know how to run this in another path.
Python output is telling me that:
Working directory: C:\Users\"my path"\laravel\public
Does anyone know how to run this?
You can pass the working directory as the second argument of the process class
So it can be:
$process = new Process('C:\Python\python.exe C:\Users\"my path"\laravel\storage\app\images\cargaExcel.py', "/my/working/path/");
Also you may pass command as array
$process = new Process(['C:\Python\python.exe', 'C:\Users\"my path"\laravel\storage\app\images\cargaExcel.py'], "/my/working/path/");

folder path with space giving error in subprocess.call

drivesToMap = ["R: \\\\server1\folder", "G: \\\\server1\folder withSpace"]
for eachDrive in drivesToMap:
call("net use " + eachDrive)
In python 3 on a windows 10 machine I am getting the following error for the code above :
System error 1232 has occurred.
The network location cannot be reached. For information about network troubleshooting, see Windows Help.
How do I resolve the space? When I type in the command from a doc cmd it works succussfully:
net use G: \server1\folder withSpace
You likely need to wrap the drive in an additional set of quotes, since net use is a command prompt command it is anticipating that the drive name (which has spaces) is actually multiple arguments instead of one.
For instance:
drivesToMap = ["'R: \\\\server1\folder'", "'G: \\\\server1\folder withSpace'"]

Can not launch sparkR

I have installed Spark 2.0 and try the sparkR command. But command occurs error message like below. Others are OK (spark-shell, pyspark,,,). Please help...
[Error message]
Dongkils-MacBook:spark-2.0.0-bin-hadoop2.7 dongkillee$ sparkR
env: R: No such file or directory
R: No such file or directory
In windows this error when system not found the R.exe file. Correct with change PATH environment
It sounds like maybe SPARK_HOME is not set. Run the Terminal app to get a command prompt and check with:
ECHO $SPARK_HOME
If the result does not list the directory where you installed Spark, then there's advice here:
What to set `SPARK_HOME` to?
In R, or R Studio you can set SPARK_HOME from within R like this:
spark_path <- '/path_to_spark/spark_dir'
Sys.setenv("SPARK_HOME" = spark_path)
you also need to add the SparkR library location in R:
spark_lib <- paste(spark_path, "/R/lib", sep="")

How to load a raster layer using PyQGIS?

Although there are some posts on this matter, there is no answer in anyone of them. This is why I am asking it again.
One post I found was https://gis.stackexchange.com/questions/68032/raster-layer-invalid
I read information from the following link: https://hub.qgis.org/wiki/17/Arcgis_rest .
I used the command: gdal_translate "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty=true" s.xml -of WMS. And it generated the file successfully. However, when I try to open the file and assuming the provider is wms, the code report layer is invalid.
The code I used is:
file = QFileDialog.getOpenFileName(self,
"Open WMS", ".", "WMS (*.xml)")
fileInfo = QFileInfo(file)
# Add the layer
layer = QgsRasterLayer(file, fileInfo.fileName(),"wms")
if not layer.isValid():
print "Failed to load."
return
I just choose the file from the dialog box.
I also tried the other command: qgis.utils.iface.addRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty=true","raster") by using the following code:
layer = QgsRasterLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer?f=json&pretty=true", "layer")
if not layer.isValid():
print "Failed to load."
return
It also report "Failed to load". The original command can be run successfully in QGIS python command line. Also, if I try to enter the code in python console, the layer.isValid() would return true. It is just not working in standalone script.
Answer can be found here: https://gis.stackexchange.com/questions/120823/how-to-load-a-wms-layer-using-pyqgis.
Basically, it is just a version problem. If you have qgis previous than v2.6, it would not work. But it is fixed for 2.6
If it is still not working for you, you most likely have problem for environment variable settings.
This is working for me for single band image.I am using python 2.7 and QGIS 2.0.1 .You can load any raster layer like wms,tiff (single band or multiband) etc. using this.:
def ifile(self):
global fileName
fileName = str(QtGui.QFileDialog.getOpenFileName(self.iface.mainWindow(),"Open Raster File",'C:\\',"raster files(*.tif *.tiff *.TIF *.TIFF *.IMG *.img )"))
if len(fileName) is 0:
return
else:
self.inFileName = fileName;
filelayer = QgsRasterLayer(fileName,os.path.basename(fileName))
if filelayer == None or filelayer.bandCount() != 1:
self.errorMessage = "Not a DEM Image"
QMessageBox.information(self.iface.mainWindow(), "Error", self.errorMessage)
else:
#f=open(str(self.inFileName))
self.dlg.lineEdit.setText(self.inFileName)
if filelayer.isValid():
QgsMapLayerRegistry.instance().addMapLayer(filelayer)
pass

Resources