How to install GDAL/scipy using cmd in window? - python-2.7

I downloaded scipy-0.17.0-cp27-none-win_amd64.whl and GDAL-1.11.4-cp27-none-win_amd64.whl from gohlke in C:\Python27\Scripts
To install I used
pip install scipy-0.17.0-cp27-none-win_amd64.whl
pip install GDAL-1.11.4-cp27-none-win_amd64.whl
It says the installation is complete but when I import the libraries as
import scipy
import gdal
it shows error as
No module named gdal
No module named gdal
However, I installed the matplotlib, numpy in the very same way and they are working absolutely fine.

I solved this problem eventually to found the mistake in my approach.
This problem can occur with anyone using ArcGIS in one's system.
ArcGIS comes with it's default Python package and if one installs python separately, each time the new libraries gets installed in the newer Python installation not in ArcGIS.
Therefore, the pyhton IDLE which one uses need to be from another Python installation.
Here in my case, ArcGIS has Python 2.6 and I have made an separate installation using Python 2.7.11.
All the libraries were getting installed in right place but I was opening the wrong IDLE to write scripts hence getting error.

Related

Python 2.7 Opencv error, ImportError: DLL load failed: The specified module could not be found

Working on python 2.7(not anaconda). Operating system Windows server 2012 R2
The pypi installation mentions two fixes for this, installing Visual C++ redistributable 2015 and Universal C Runtime.
As well as a manual fix for older anaconda versions, which is for python3(I am not using anaconda version, and also my python version is 2.7 so presuming it doesn't apply in my case)
link here:
https://pypi.org/project/opencv-python/
installed both the dependencies but couldn't get it to work.
Any ideas on how I may fix this?
Since Python 2.7 is still supported, this could be the possible solution.
Installing OpenCV from prebuilt binaries:
Below Python packages are to be downloaded and installed to their default locations.
Python-2.7.x
Numpy
Matplotlib
Install all packages into their default locations. Python will be installed to C:/Python27/.
After installation, open Python IDLE. Enter import numpy and make sure Numpy is working fine.
Download latest OpenCV release and install it : Latest OpenCV-build
Goto opencv/build/python/2.7 folder.
Copy cv2.pyd to C:/Python27/lib/site-packeges.
Open Python IDLE and type following codes in Python terminal.
import cv2
print cv2.__version__

too many pythons on linux

i recently started using python with xubuntu on virtualbox but i'm having problems. I want to be able to use numpy so i thought that apt-get install python-numpy would solve everything, but using the shell i kept getting No module named numpy. I used IDLE and it could find it. I also have IDLE (using Python-2.7), and again it could import numpy. Then i noticed that the shell had python 2.7.9, while the IDLEs had python 2.7.6.
Using
import sys
print sys.path
this if what i get from 2.7.9 (shell)
/usr/local/lib/python2.7/site-packages/setuptools-17.0-py2.7.egg
/usr/local/lib/python2.7/site-packages/Pillow-2.3.0-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/site-packages/mock-1.0.1-py2.7.egg
/usr/local/lib/python27.zip
/usr/local/lib/python2.7
/usr/local/lib/python2.7/plat-linux2
/usr/local/lib/python2.7/lib-tk
/usr/local/lib/python2.7/lib-old
/usr/local/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/site-packages
and from 2.7.6 (IDLE)
/home/alessandro
/usr/bin
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/pymodules/python2.7
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
I understand that i have two versions of python installed and somehow i ended up installing packageg into only one of them (the 2.7.6).
I'd like to be able to use 2.7.9 both in the shell and in IDLE and also i'd like to install so that python 2.7.9 can see them.
I read that i can add paths to the python sys.path, but isn't there a more efficient/persistent way to do what i want?
PS: tell me if you need more informations
For my projects I usually create a virtualenv for each python version I need for the project at hand. I manage them using pip to install specific versions that I need. Moreover you should be able to choose the python path in your IDE. While I'm not using IDLE, I read here that apparently idle comes along with the python versions during install. So maybe your idle versions collide with each other. If you want to have only one python version at the time on your machine you might consider a simple remove and fresh install of your desired version. Again I would recommend pip over apt-get etc. Hope this is of help for you.
Worth to check PyDev, a plugin for Eclipse to work on python.
http://marketplace.eclipse.org/content/pydev-python-ide-eclipse , or http://pydev.org/.
This allows you to configure the python version for different project's.
I have some project's with python 2.7 and others with 3.4.
it's checks the whole system in search for the PYTHONPATH to use!

Error "from scipy.linalg import _fblas importerror: DLL load failed"

I found a code on internet which implement a paper "Effective 3D Action
Recognition Using EigenJoints" code. They implement in Python so I tried to install Python 2.7.9 and numpy, scipy, scikit-learn. All these libraries installed successfully. In the cmd when i tried to run python eigen.py it gives me this error.
Please anyone download this code and run it by yourself or help me to solve this error.
You have to do 2 steps:
download anaconda according to your system and specifications.
Make sure that Anaconda is installed on python version installed on your system. For example, if you have python 3.4, and anaconda in installled on 2.7, then you should remove python 3.4.
Afterwards, the code will run smoothly and all libraries will be well defined. I have made the same ;) Please, let me know if you face new problems.

import pygtk works but not import gtk

I am configuring pygtk in my centos 5.4 machine. But I am facing few issues.
I want pygtk to be configured to Python 2.7(The default python version is Python 2.4 in centos 5)
So I installed Python 2.7 with different --prefix to my local space and then installed pygobject2.28 and then pygtk2.24 with the --prefix="where python 2.7 installed".
But when I run python2.7 interpreter I am able to import pygtk but, when I try to import gtk it says "no module named gtk."
I have configured PYTHONPATH and PYTHON environment variables to python2.7/lib/site-packages and python2.7 respectively.
My questions:
if pygtk is a wrapper for gtk then why am not able to import gtk, when I am able to import pygtk.
Where does python(or pygtk) pick the gtk from?
And how can I solve the above problem!?
I tried google and other stack overflow questions. But none of them answered the above quesions.
I wasn't checking the ./configure output properly. The problem was, I was trying to install gtk and pygtk without installing cairo and pango. So pygtk skipped building gtk packages because it did not find any cairo package. This was mentioned in the ./ configure script but I had not checked that.
Summarizing:
To configure pygtk to python need to folow these steps
install sqlite-devel #If sqlite needed
install python(2.7)
install gtk(2.24.0) -> requires glib(2.27.3), atk(1.29.2), cairo(1.8.10), pango(1.22.4), gdk-pixbuf(2.21.3)
install pygtk(2.24.0) -> requires pygobject-2.28.3, pycairo(1.8.10)
All the above packages must be compiled to the same prefix, and need to set the PYTHON and PATHONPATH environment variables. The versions of packages also play major role. Added version in parenthesis that worked for me.
There are many dependencies while installing some of the packages so I had to install following packages using yum: libxext, librender, gettext, zlib, libgtk2-devel

ImportError when importing certain modules from SciPY

I have used Scipy for some time. This is the first time I am using it for Signal processing!
But when I import modules like
from scipy import signal
from scipy import special
I get the error:
ImportError: DLL load failed: The specified module could not be found.
I am using Python 2.7.3 with Scipy 0.12.0 on 32-Bit Windows.
What should I do ?
This problem can be solved if instead of installing the usual numpy distribution, the numpy-MKL package is installed.
This package is available here.
Do remove the previous installation before going with the new one!
I already had numpy+mkl installed, but still I faced similar error.
Reinstalling has solved the issue:
pip uninstall numpy-1.13.1+mkl-cp35-cp35m-win_amd64.whl
pip install numpy-1.13.1+mkl-cp35-cp35m-win_amd64.whl
I installed numpy-MKL from here for Python 3.5.1, but it didn't solve the problem until I added the folder C:\Program Files\Python35\Lib\site-packages\numpy\core to system path.
Similar to the OP, I already had the Intel MKL libraries installed on my system. I was unable to load scipy.linalg with the same error message. I uninstalled the old version of numpy and scipy (which I installed before installing the Intel compilers and math libraries). Then ran pip install scipy, and magically I could now import scipy.linalg without the error.
I'm not entirely sure what caused it, and why it was unable to find the library it needed. But it somehow fixed the problem for me on Python 3.7.1 with Anaconda.
I had an issue importing sklearn because of my Scipy installation.
I fixed this by going to here and downloading the right version of numpy for my computer. Then I did the same for Scipy by going here and downloading the MKL version for my computer.
Once I did that, everything worked!
To check the supported tags for wheel version for your system you can run the following command in the command prompt: pip debug --verbose.
You can install the .whl files for numpy and scipy by doing: pip install {filename}.whl
I had this issue on 3.6 and reinstalling didn't work,downloading the wheel didn't work. I found a solution that did work:
go to "site-packages/scipy" folder and open __init__.py file for editting.
At the very bottom add this line of code:
from . import signal
from . import special
from . import linalg
from . import <insert missing submodule here>
this is the only solution that has worked for me and it should work for any one