简体   繁体   English

Windows 7命令提示符下的Python模块导入错误

[英]Python module import error with command prompt of Windows 7

I have a script in Python where i import several modules 我在Python中有一个脚本,我在其中导入了几个模块

from __future__ import division
import os
import glob
import sys
import tempfile
import shutil
import math
import datetime
import gdal
import random
from shapely.geometry import Point
from shapely.geometry import Polygon
from shapely.geometry import box
from liblas import file

when i use an IDLE (es: PyCharm or PyScripter) i have no problem to import the external modules (gdal, shapely.geometry, and liblas). 当我使用IDLE(例如:PyCharm或PyScripter)时,导入外部模块(gdal,shapely.geometry和liblas)没有问题。 When i run the script i got this error message 当我运行脚本时,出现此错误消息

C:\PythonScript\myscript.py
Traceback (most recent call last):
File "C:\PythonScript\myscript.py", line 10, in <module>
import gdal
ImportError: No module named gdal
where

print(gdal.__file__)
C:\Python27\lib\site-packages\gdal.pyc
and

print(sys.path)
['C:\\Program Files (x86)\\JetBrains\\PyCharm 2.7.3\\helpers\\pydev', 'C:\\Python27\\lib\\site-packages\\progressbar-2.3-py2.7.egg', 'C:\\windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\PythonScript']

i installed gdal using Unofficial Windows Binaries for Python Extension Packages using an file *.exe. 我使用* .exe文件使用非官方Windows二进制文件的Python扩展包安装了gdal。

Try to check the path of Python install and site-packages. 尝试检查Python安装路径和站点程序包。 if something wrong with that, your system might not be able to find the modules and site-packages which may cause such errors. 如果这有问题,您的系统可能无法找到可能导致此类错误的模块和站点程序包。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM