Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using pip to install modules in python failing

I'm having trouble installing python modules using pip. Below is the output from the command window:

Note that I installed pip immediately before trying to install GDAL module.

I am on a w7 64bit machine running python 2.7

    Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\jnunn\Desktop>python get-pip.py
Downloading/unpacking pip
Downloading pip-1.2.1.tar.gz (102Kb): 102Kb downloaded
Running setup.py egg_info for package pip

warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory
'docs\_build'
no previously-included directories found matching 'docs\_build\_sources'
Installing collected packages: pip
Running setup.py install for pip

warning: no files found matching '*.html' under directory 'docs'
warning: no previously-included files matching '*.txt' found under directory
'docs\_build'
no previously-included directories found matching 'docs\_build\_sources'
Installing pip-script.py script to C:\Python26\ArcGIS10.1\Scripts
Installing pip.exe script to C:\Python26\ArcGIS10.1\Scripts
Installing pip.exe.manifest script to C:\Python26\ArcGIS10.1\Scripts
Installing pip-2.7-script.py script to C:\Python26\ArcGIS10.1\Scripts
Installing pip-2.7.exe script to C:\Python26\ArcGIS10.1\Scripts
Installing pip-2.7.exe.manifest script to C:\Python26\ArcGIS10.1\Scripts
Successfully installed pip
Cleaning up...

C:\Users\jnunn\Desktop>pip install gdal
Downloading/unpacking gdal
Downloading GDAL-1.9.1.tar.gz (420kB): 420kB downloaded
Running setup.py egg_info for package gdal

Installing collected packages: gdal
Running setup.py install for gdal
building 'osgeo._gdal' extension
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo
/Ox /MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -I
C:\Python26\ArcGIS10.1\include -IC:\Python26\ArcGIS10.1\PC -IC:\Python26\ArcGIS1
0.1\lib\site-packages\numpy\core\include /Tpextensions/gdal_wrap.cpp /Fobuild\te
mp.win32-2.7\Release\extensions/gdal_wrap.obj
gdal_wrap.cpp
c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) :
warning C4530: C++ exception handler used, but unwind semantics are not enabled
. Specify /EHsc
extensions/gdal_wrap.cpp(2853) : fatal error C1083: Cannot open include file
: 'cpl_port.h': No such file or directory
error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\c
l.exe"' failed with exit status 2
Complete output from command C:\Python26\ArcGIS10.1\python.exe -c "import se
tuptools;__file__='c:\\users\\jnunn\\appdata\\local\\temp\\pip-build\\gdal\\setu
p.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'
))" install --record c:\users\jnunn\appdata\local\temp\pip-f7tgze-record\install
-record.txt --single-version-externally-managed:
running install

running build

running build_py

creating build

creating build\lib.win32-2.7

copying gdal.py -> build\lib.win32-2.7

copying ogr.py -> build\lib.win32-2.7

copying osr.py -> build\lib.win32-2.7

copying gdalconst.py -> build\lib.win32-2.7

copying gdalnumeric.py -> build\lib.win32-2.7

creating build\lib.win32-2.7\osgeo

copying osgeo\gdal.py -> build\lib.win32-2.7\osgeo

copying osgeo\gdalconst.py -> build\lib.win32-2.7\osgeo

copying osgeo\gdalnumeric.py -> build\lib.win32-2.7\osgeo

copying osgeo\gdal_array.py -> build\lib.win32-2.7\osgeo

copying osgeo\ogr.py -> build\lib.win32-2.7\osgeo

copying osgeo\osr.py -> build\lib.win32-2.7\osgeo

copying osgeo\__init__.py -> build\lib.win32-2.7\osgeo

running build_ext

building 'osgeo._gdal' extension

creating build\temp.win32-2.7

creating build\temp.win32-2.7\Release

creating build\temp.win32-2.7\Release\extensions

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox
/MD /W3 /GS- /DNDEBUG -I../../port -I../../gcore -I../../alg -I../../ogr/ -IC:\P
ython26\ArcGIS10.1\include -IC:\Python26\ArcGIS10.1\PC -IC:\Python26\ArcGIS10.1\
lib\site-packages\numpy\core\include /Tpextensions/gdal_wrap.cpp /Fobuild\temp.w
in32-2.7\Release\extensions/gdal_wrap.obj

gdal_wrap.cpp

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : war
ning C4530: C++ exception handler used, but unwind semantics are not enabled. Sp
ecify /EHsc

extensions/gdal_wrap.cpp(2853) : fatal error C1083: Cannot open include file: 'c
pl_port.h': No such file or directory

error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.ex
e"' failed with exit status 2

----------------------------------------
Command C:\Python26\ArcGIS10.1\python.exe -c "import setuptools;__file__='c:\\us
ers\\jnunn\\appdata\\local\\temp\\pip-build\\gdal\\setup.py';exec(compile(open(_
_file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\u
sers\jnunn\appdata\local\temp\pip-f7tgze-record\install-record.txt --single-vers
ion-externally-managed failed with error code 1 in c:\users\jnunn\appdata\local\
temp\pip-build\gdal
Storing complete log in C:\Users\jnunn\pip\pip.log

C:\Users\jnunn\Desktop>

I have tried to use easy_install before too, and it came back with a common error to this:

c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\INCLUDE\xlocale(342) : war
ning C4530: C++ exception handler used, but unwind semantics are not enabled. Sp
ecify /EHsc

extensions/gdal_wrap.cpp(2853) : fatal error C1083: Cannot open include file: 'c
pl_port.h': No such file or directory

error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.ex
e"' failed with exit status 2

Plus the following additional pip.log:

    Exception information:
Traceback (most recent call last):
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\basecommand.py", line 107, in main
status = self.run(options, args)
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\commands\install.py", line 261, in run
requirement_set.install(install_options, global_options)
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\req.py", line 1166, in install
requirement.install(install_options, global_options)
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\req.py", line 589, in install
cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
File "C:\Python26\ArcGIS10.1\lib\site-packages\pip\util.py", line 612, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command C:\Python26\ArcGIS10.1\python.exe -c "import setuptools;__file__='c:\\users\\jnunn\\appdata\\local\\temp\\pip-build\\gdal\\setup.py';exec(compile(open(__file__).read().replace('\r    \n', '\n'), __file__, 'exec'))" install --record c:\users\jnunn\appdata\local\temp\pip-f7tgze-record\install-record.txt --single-version-externally-managed failed with error code 1 in c:\users\jnunn\appdata    \local\temp\pip-build\gdal
like image 718
James N Avatar asked Sep 20 '12 11:09

James N


People also ask

Why is pip install not working in Python?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.

Why can't I install Python packages?

The first reason that prevents you from installing the latest package versions is dependency error. A possible solution is to check the latest versions of the package and to install one which is: supported by your version. doesn't have dependency issues.

Does Python 3.10 support pip?

The current version of pip works on: Windows, Linux and MacOS. CPython 3.7, 3.8, 3.9, 3.10 and latest PyPy3.


2 Answers

The problem is that Python thinks to be installed on C:\Python\ but this is not true as it is inside portablepython directory. I resolved this using a link.

For instance my portablepython directory (or kivy directory in example) is this:

C:\Users\blabla.KMS\kivy-1.8.0-py3.3-win32\Python33

enter dos prompt and type:

mklink /d c:\Python33\ C:\Users\blabla.KMS\kivy-1.8.0-py3.3-win32\Python33\ 

than you can go inside c:\Python33\Scripts and use PIP or easy_install finally you can delete the link using:

rmdir Python33

Cool! I installed Django on kivy!

like image 96
piertoni Avatar answered Oct 10 '22 16:10

piertoni


This issue looks very similar to Python GDAL package missing header file when installing via pip which seems to have working solution.

Usual problem with python libraries that have CPython extensions is explained here and solution is often:

install library by downloading and running windows binary package.

like image 37
Robert Lujo Avatar answered Oct 10 '22 16:10

Robert Lujo