2012-09-20 64 views
12

我在使用pip安装python模块时遇到了问题。以下是命令窗口的输出:使用pip在python中失败安装模块

请注意,我在尝试安装GDAL模块之前立即安装了pip。

我在W7 64位机器上运行的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> 

我已经尝试过也使用easy_install的,并将其与常见的错误又回到了这一点:

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 

加上以下额外的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 
+2

你可以使用二进制安装程序从http://www.lfd.uci.edu/~gohlke/pythonlibs/ – jfs

+0

安装'gdal'也许这论坛的帖子可以帮你:HTTP:/ /ubuntuforums.org/showthread.php?t=1769445 –

回答

1

这不是Python问题,而是编译问题在Windows上的来源。

我假设你遵循了installation instructions并首先安装了GDAL二进制文件和头文件?

此外,你可以检查this SO question的答案,它指向一个ubuntu forum可以帮助你。

2

问题安装就是,Python认为要对安装在C:\ Python的\但是,因为它是内部portablepython这是不正确目录。 我使用链接解决了这个问题。

比如我portablepython目录(或例如kivy目录)是这样的:

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

进入DOS提示符下键入:

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

比你可以去里面C:\ Python33 \ Scripts中并使用PIP或easy_install 最后您可以删除使用的链接:

rmdir Python33 

酷!我在kivy上安装了Django!

+0

'mklink/dc:\ Python33 \ C:\ Users \ blabla.KMS \ kivy-1.8.0-py3.3-win32 \ Python33 \'正在生成错误我:'当文件已经存在时不能创建文件。'你知道为什么吗?即时通讯使用以下命令:'mklink/d“C:\ Python27 \”“C:\ Users \ USR01 \ virtualenvs \ env1 \”'作为管理员... – jes516

+0

这不能工作。 1)c:\ Python33 \已经存在,因此当您尝试将c:\ Python33 \链接到您的虚拟环境时会引发错误,反之亦然,当您尝试将c:\ Python33 \链接到您的虚拟环境时,因为虚拟环境已经创建。 – jes516

+0

我用这个方法在portablepython和kivy里安装了包,所以在我的情况下,目录c:\ Python33 \不存在。 – piertoni

0

我有同样的问题,但我需要安装'ebooklib'模块,它不在http://www.lfd.uci.edu/~gohlke/pythonlibs模块列表中。同时我下载了这个模块。但安装与ebooklib的setup.py失败 error: command '"c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.ex e"' failed with exit status 2 Finnally,我已经安装了所有依赖模块,分别从lfd.uci.edu和安装setup.py成功后。

0

我试图在没有anaconda的情况下安装ipython时遇到了类似的问题。当pip安装jupyter和添加到PATH后,第一个点无法找到'cl.exe',我得到了退出状态2错误的失败。

您可以尝试使用VS文件才能正常工作,但它周围的最简单的办法,我打转转是:

1)下载从https://pypi.python.org/pypi 2 .tar.gz文件)中提取的在提取的文件夹文件夹 3)运行setup.py从CMD:

c:\> cd <wherever your extracted folder is from .tar.gz that contains setup.py> 
c:\<yourcdhere>>python setup.py install 

注意如果像我一样,你没有蟒蛇的路径,因为你有不同的事情蟒蛇32B和64b,你会必须手动指向python(将第二个命令更改为):

c:\<yourcdhere>>pythoninstallpath\python setup.py install 

它会自动复制该库并将其所有依赖项安装到相应lib文件夹下的python安装位置。

所以你可以看到它是如何工作的,在这里它是为我。但改变目录以匹配你正在使用的任何东西:

我有解压文件夹ipython的setup.py在“L:\ python \ py27_32b \ ipython-5.3.0” 和python安装在“L:\ python \ py27_32b \ install“

c:\users\vlox>L: 
L:\>cd "python\py27_32b\ipython-5.3.0" 
L:\python\py27_32b\ipython-5.3.0>L:\python\py27_32b\install\python setup.py install 

和瞧!

希望这有助于