How to install gdal_merge to run with osgeo? - gdal

I recently installed OSGEO (http://download.osgeo.org/) which included python and gdal. I just realised however that there are many gdal libraries that were not included in this package for example gdal_merge. How can I install them into the osgeo environment?

Go to this link:
gdal_merge.py
Copy everything and save the script as gdal_merge.py.
Put the gdal_merge.py to the your gdal libraries directory(osgeo directory).

On Windows, in the OSGeo4W setup program, gdal_merge.py and the other GDAL Python scripts are included in the gdal-python package in the Libs Category.
When installed, the Python scripts are copied to the bin subdirectory within the OSGeo4W installation directory along with batch files to launch the Python scripts. (For example, gdal_merge.bat).
Once installed, the GDAL Python scripts can be executed from the OSGeo4W Shell which is available from the Windows Start Menu.

Related

Python error importing dll files while py file import is successful

I have the setup as seen in the attached image:
Both the pyd and functions.py file are defined in the same folder yet the error is only at importing pyd file.
The error is ModuleNotFoundError: No module named marketPriceMarcoPolo
I am not sure what is going on.
Edit:
The pyd file was generated on Python 3.7 and is being used on a PC with Python 3.8 installed. Does it matter?
The pyd file was generated on Python 3.7 and is being used on a PC with Python 3.8 installed. Does it matter?
Yes, it matters. It's in the name of the build (.cp37-amd_win64). That means the extension is built for use with CPython 3.7 64-bit on Windows.
Extensions are linked to an explicit Python version. When you run your script on Python 3.8, it will look for marketPriceMarcoPolo.cp38-win_amd64.pyd instead. Build it with the Python you intend to use it with.

PyDev Jython - Install and import Python library

I'm using Jython to script in runtime in a plugin based on Java in Eclipse.
When I want to use Python libraries (py_expression_eval, for example) on the scripts, what I'm doing is:
1) install the library using easy_install in Jython standalone (it is installed in: C:\jython2.7.0\Lib\site-packages\py_expression_eval-0.3-py2.7.egg)
2) copy the folder py_expression_eval to C:\eclipse\plugins\org.python.pydev.jython_4.5.5.201603221110\Lib\site-packages
3) in the script, before importing the library, add this folder above to the classpath using sys.path.append()
Is there a way I can install a python library directly to a folder in the classpath, so I could just import the library? What I have in mind is that the Jython standalone has a bin folder with easy_install and pip, but PyDev.Jython does not.

Cannot run standalone psychopy if PYTHONPATH and PYTHONHOME set for different python version

I thought that the standalone PsychoPy install could coexist happily if Python was installed separately on the PC to but I can't get it to, nor can I find any docs. (I'm using Windows 7)
I have the lastest standalone version installed and the shortcut to run it is
"D:\Program Files (x86)\PsychoPy2\pythonw.exe" "D:\Program Files (x86)\PsychoPy2\Lib\site-packages\PsychoPy-1.81.02-py2.7.egg\psychopy\app\psychopyApp.py"
This works fine if my system env variables for PYTHONHOME & PYTHONPATH aren't set but I also use Python for other apps and need them setting to point to the other version of Python I have installed natively. When these env vars are set, Psychopy fails to load and gives no error messages at all.
Can anyone advise how I get them to play together nicely? (I thought it used to work last year, has something changed?)
[ I've tried a full uninstall of psychopy and freshly installed the latest standalone version v1.81.02
Yes, this is an unfortunate consequence of the way that PsychoPy is currently bundled with it's own closed environment in it's own python and dependencies installed seperately.
However, a new option to install psychopy using the conda package manager was introduced recently for Mac OS but some have also got it to work on Windows with a bit of tweaking.. Work is currently ongoing for this feature. I doubt that it was working previously unless you manually installed all dependencies in your default python, or ran linux:
On linux you can simply install psychopy from the neuro.debian repository, making it available for python system-wide. See PsychoPy documentation.
Thinking about it, I don't think it would ever worked if you had set PYTHONPATH (I don't know about PYTHONHOME).
BUT I did have a 'regular' python installation running alongside my Standalone PsychoPy install by not using the PYTHONPATH variable. You can add further paths to your python importing path (I assume that's the aim here) without setting any environment variable by adding text files ending in .pth to your site-packages directory. Essentially any lines in a .pth file that is found while navigating the existing path will also be added to the path!
Actually, according to the python docs you can also set a flag -E to ignore the environment variables:
https://docs.python.org/2/using/cmdline.html
To use that solution for the Standalone PsychoPy installation you'd have to alter the application shortcut to add this (that should get the app to load), but also make a couple of changes to the code for running scripts so that they also run with the flag set.
I still think not setting those variables is the easier solution though.
cheers,
Jon

ValueError: Symbol table not found

I'm trying to install scikit-learn; following the instructions, I downloaded the source and attempted to install it with python setup.py install, however the installation is interrupted at:
File "C:\Users\Alpine\Anaconda\lib\site-packages\numpy\distutils\mingw32ccompi
ler.py", line 278, in generate_def
raise ValueError("Symbol table not found")
ValueError: Symbol table not found
I've also tried using easy_install -U scikit-learn, although end up with the same error.
Using conda install scikit-learn appeared to install the conda-3.4.1-py27_0.tar.bz2 and numpy-1.8.1-py27_0.tar.bz2 packages, and for safe measure I ran conda update anaconda, although I'm still receiving the same error.
Would anybody know how to work around this?
This solution will take care of "symbol table not found" error from numpy (or any other package ) on windows machine
sklearn people have provided good solution for this over here
http://scikit-learn.org/stable/developers/advanced_installation.html#building-on-windows
you can find instruction for Linux and mac on same page
now just follow these steps
32-bit Python
For 32-bit python it is possible use the standalone installers for microsoft visual c++ express 2008 for Python 2 or Microsoft Visual C++ Express 2010 for Python 3.
Once installed you should be able to build scikit-learn without any particular configuration by running the following command in the scikit-learn folder:
python setup.py install
64-bit Python
For the 64-bit architecture, you either need the full Visual Studio or the free Windows SDKs that can be downloaded from the links below.
The Windows SDKs include the MSVC compilers both for 32 and 64-bit architectures. They come as a GRMSDKX_EN_DVD.iso file that can be mounted as a new drive with a setup.exe installer in it.
**For Python 2 you need SDK v7.0: MS Windows SDK for Windows 7 and .NET Framework 3.5 SP1 -> https://www.microsoft.com/en-us/download/details.aspx?id=18950
For Python 3 you need SDK v7.1: MS Windows SDK for Windows 7 and .NET Framework 4** -> (can't post link as i need atleast 10 reputation point )
Both SDKs can be installed in parallel on the same host. To use the Windows SDKs, you need to setup the environment of a cmd console launched with the following flags (at least for SDK v7.0):
cmd /E:ON /V:ON /K
Then configure the build environment with:
SET DISTUTILS_USE_SDK=1
SET MSSdk=1
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Setup\WindowsSdkVer.exe" -q -version:v7.0
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd" /x64 /release
after typing above commands in cmd as soon as you hit enter the window will be changed lil bit ( font color changed to green ) now go to directory where you have downloaded sklearn zip file from git hub then un-zip it
and go to directory where you can find setup.py
run command
python setup.py install
if it's not recognizing python then you migh have missed this command
cmd /E:ON /V:ON /K
so till now if u have done everything correct then your package will be installed without any difficulties

PyCharm and external libraries

I have started to use PyCharm IDE, but I was not able to determine how to manage external libraries there. For instance, PyCharm does not see matplotlib. In PyCharm's file manager, I clearly see the list of external libraries and there is no matplotlib. However, I have it installed and I know its location.
How can I add this library to PyCharm environment?
I suggest to use Python virtual environment. It is really easy with PyCharm.
PyCharm > Preferences... > Project Interpreter > Python Interpreters
Click "Create Virtual Environment" and pick your base interpreter.
Click "Install" and install any packages you need. You can also add other repositories if the default ones do not contain required libraries. Another benefit is that you can see which libraries have newer version and can be updated.
I think one way to solve a problem is to specify your interpreter in PyCharm itself via File -> Settings -> Python Interpreters
There is also a Paths tab in this setting, you need to add path to your matplotlib explicitly there. But for me there is no special path listed there. Here are my paths in this tab:
file://D:/hg_work/vefw_regression/tools/python/DLLs
file://D:/hg_work/vefw_regression/tools/python/Lib
file://D:/hg_work/vefw_regression/tools/python/Lib/lib-tk
file://D:/hg_work/vefw_regression/tools/python
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages (my matplotlib/numpy and other stuff is here)
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/win32
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/win32/lib
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/pythonwin
file://D:/Users/svecovs/AppData/Roaming/JetBrains/PyCharm Community Edition 3.0.1/helpers/python-skeletons
file://D:/hg_work/vefw_regression/tools/python/Lib/site-packages/core (added by user)
Install matplotlib and then python-tk.Pycharm will function well.It's working for me at Ubuntu 16.04.
sudo apt-get install python-tk
sudo apt-get install python-matplotlib
For Linux Users here is a solution ,
firstly write this command in the terminal ,
sudo apt-get install python-matplotlib
Now you're done you will be able to see matplotlib in File>>>settings>>project interpreter.
Image
Solve this problem by choosing system interpretator.