pyDEA running as a python script - python

I am attempting to run pyDEA. The main_gui approach does not work from wha appears to be the
ValueError: cannot use LOCALE flag with a str pattern
issue with the latest version of Python (I am running Python 3.8.5, Anaconda on MacOS).
Has anyone run it directly in a script? If so, do they have any sample code to show what they needed to import and call to run the DEA analysis?

Related

My python installation on 1and1 stopped working (bashrc issue)

I installed python 2.7.10 on my 1and1 linux hosting service about 8 months ago (using instructions from http://geeksta.net/geeklog/python-shared-hosting/) and everything was working fine (I had a daily cron job that would call my python script). But recently,my python script stopped working and it appears that the call to python itself is the culprit, rather than the python code. Whenever I type 'python' into the command line in the 1and1 unix ssh session now, i get the following error message
"-bash: /kunden/homepages/26/xxxxxxxxxx/htdocs/python27/bin/python: No
such file or directory"
It's been awhile since I installed things, but I don't believe I had this issue previously. I'm trying to figure out why it's not working and what I can do to get it fixed. It appears that calling python isn't working properly (which would affect my script as well).
Any help with getting this working would be greatly appreciated.
when you type python, system find it in /kunden/homepages/26/xxxxxxxxxx/htdocs/python27/bin/python, but there is no such a file in fact.
what you need to do is trying to locate your python binary executable file, and alias your python to your file
I ended up just reinstalling python 2.7 again and it works again. Not sure why it stopped working before.
Now I can type "python" in the command line and it starts the Python console.

Python run file from command line

Yesterday I installed Python (with Numpy & Scipy) on CentOS, everthing works fine when I'm using the CLI and do some math. But now I try to execute a file, and then a weird error appears, searched all over the place but can't find the solution to fix this.
I'm running two Python versions, the version I'm using is 3.4, and I installed it at: /usr/local/bin
Then I made a file called test.py in the same directory, with this code:
import numpy
When I try to run it with:
./python3.4 -m test.py
I get this error:
/usr/local/bin/python3.4: Error while finding spec for 'test.py' (<class 'AttributeError'>: 'module' object has no attribute '__path__')
I hope somebody can lead me into the right direction, thanks in advance!
Running things like
python -m <something>
invokes Python, which then tries to import a Python Module.
From your short example it doesn't appear to be a valid Python module
Try running with python <your python code file> instead.

Can't get Python IDLE to recognize OGR/GDAL Module

Folks,
Just getting started using OGR and Python for a variety of geospatial tasks. I'm working outside of OSGEO4w, and have installed GDAL w/ Python Bindings as well as Python v. 2.7.8 on my machine.
That said, I can run python and import gdal from a command-line interface but am unable to import the module when I use the IDLE environment. It returns an error telling me that the module doesn't exist. My install must be sound given that it works in the cmd prompt, so what's the deal?
This is all new to me, I'd appreciate any help or advice ya'll can impart; all previous questions I've read were concerned w/ merely installing (which I've done successfully) and getting Python to recognize the module from the command prompt, which it does.
Cheers,
Mike
Mike,
You can open IDLE with your python installation from the cmd line through:
>>>from idlelib import PyShell
>>>PyShell.main()
This should open IDLE from your current python, and you should be able then to import gdal and ogr from there.
Alternatively, you should have a windows batch file here
C:\YOURPYTHONPATH\Lib\idlelib\idle.bat
Running this should achieve the same.
Martin
Consider creating the following batch where PyInst references the Python installation folder from which IDLE is launched (i.e. idle.bat) and QgisInst references the folder containing "bin\o4w_env.bat":
#echo off
set PyInst=C:\Python27
set QgisInst="C:\Program Files\QGIS Brighton"
call %QgisInst%\bin\o4w_env.bat
set PYTHONPATH=%PyInst%\DLLs;%PyInst%\Lib;%PyInst%\Lib\lib-tk
set TCL_LIBRARY=%PyInst%\tcl\tcl8.5
python %PyInst%\Lib\idlelib\idle.pyw

VBoxManage not working from Python

I want to delete a given virtual machine installed on VirtualBox (itself installed on Windows XP). When I run the command from CMD the deletion rus as I expect. But when I run this code:
import subprocess
myVM="windowsxp_1"
status = subprocess.call(["VBoxManage", "unregistervm", myVM, "--delete"])
The deletion is performed. However, unlike in the first case, the name of the VM is still listed on the VirtualBox interface. Why and how can I resolve this problem ?
Here are 2 pictures explaining what I said:
Deletection is successful:
But the name of the VM is still listed on the VirtualBox:The result is the same when I use :
import os
os.system("VBoxManage unregistervm vmNameToDelete --delete")
I can't reproduce this problem using Python run from the command line. It appears your IDE may be affecting things. Try running your Python script from the command line to see it works there.
I'm not sure why running the script under your IDE that would cause it not to work. Maybe you've got two versions of VirtualBox installed on your machine and your IDE is using a different PATH and ends up using a different VBoxManage.

How can I run python3 on my apache server by default?

I am a beginner to Python here, and I am having an issue.
In my setup, I was using a PHP script to call the command line which in turn would execute a python script. Since then, I've discovered that I can run python directly.
My problem is that 2.6 is running when I call the script directly, and I need Python 3.3 to run instead.
After looking this up, I found I need to recompile mod_python, but then I found that I want to use mod_wsgi instead which is giving me a whole series of other errors like my python3 installation not having --shared-libraries when make was ran.
I am pulling my hair out trying to do such a seemingly simple task. Is there any direction someone can point me in? Again, I am a Python beginner. Any help is apprecited!

Categories