QGIS Python Error : No module named 'encodings' |
您所在的位置:网站首页 › 惠普打印机怎么无线连接电脑详细步骤 › QGIS Python Error : No module named 'encodings' |
I have written a python code which uses the 'Raster Surface Volume' algorithm of QGIS Desktop 3.8.3. When I execute the python code, I am getting an error : The system cannot find the path specified. Fatal Python error: initfsencoding: unable to load the file system codec ModuleNotFoundError: No module named 'encodings' Current thread 0x00002218 (most recent call first): Press any key to continue . . .I have imported the libraries as given below. from osgeo import ogr, gdal from gdalconst import * from qgis.core import * import qgis.utils, sys from qgis.gui import * from PyQt5.QtGui import * from PyQt5.QtCore import Qt from PyQt5.QtCore import QFileInfo app = QApplication([]) QgsApplication.setPrefixPath("C:/OSGeo4W64/apps/qgis", True) QgsApplication.initQgis() sys.path.append('C:/OSGeo4W64/apps/qgis/python/plugins') import processing from processing.core.Processing import Processing Processing.initialize() from processing.tools import * import os, globIn the 'Environment Variables', in the 'path' of 'user variables' section, I can find : C:\Users\sreeraj\AppData\Local\Programs\Python\Python37\Scripts\ C:\Users\sreeraj\AppData\Local\Programs\Python\Python37\I can also find the same in the 'path' of 'system variables' section in the 'Environment Variables'. In the folder 'C:\OSGeo4W64\apps\', I can find 2 folders namely 'Python37' and 'Python27'. I have installed 'python-3.7.4-amd64.exe' in my computer before installing the 'osgeo4w64'. Which means that I am using Python 3.7.4 in my computer and when I installed 'OSGeo4W64', I can find find a folder 'Python37' (along with 'Python27') which is integrated to QGIS Desktop 3.8.3. Can anyone help me with the exact solution to this error 'No module named encodings' ? As @user2856 suggested, I opened OSGeo4W command prompt, then executed py3_env, qt5_env and ran the script using python3 path\to\your\script.py . Now, I got a QGIS import error : from qgis.core import * ModuleNotFoundError: No module named 'qgis' .python-qgis.bat file in C:\OSGeo4W64\bin\ is given below : @echo off call "%~dp0\o4w_env.bat" call qt5_env.bat call py3_env.bat @echo off path %OSGEO4W_ROOT%\apps\qgis\bin;%PATH% set QGIS_PREFIX_PATH=%OSGEO4W_ROOT:\=/%/apps/qgis set GDAL_FILENAME_IS_UTF8=YES rem Set VSI cache to be used as buffer, see #6448 set VSI_CACHE=TRUE set VSI_CACHE_SIZE=1000000 set QT_PLUGIN_PATH=%OSGEO4W_ROOT%\apps\qgis\qtplugins;%OSGEO4W_ROOT%\apps\qt5\plugins set PYTHONPATH=%OSGEO4W_ROOT%\apps\qgis\python;%PYTHONPATH%"%PYTHONHOME%\python" %* I have tried the accepted answer of @Germán Carrillo of Problem with import qgis.core when writing a stand-alone PyQGIS script by running var_entorno_osgeo4w.bat in OSGeo4W64 shell as given below : run o-help for a list of available commands C:\OSGeo4W64>var_entorno_osgeo4w.bat C:\OSGeo4W64>set PYTHONPATH=C:\OSGeo4W64\apps\qgis\python C:\OSGeo4W64>set PATH=C:\OSGeo4W64\apps\qgis\bin;C:\OSGEO4~1\apps\Python37\Scripts;C:\OSGEO4~1\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\WBem C:\OSGeo4W64>Still, I am unable to solve this issue. How can I solve this QGIS import error : No module named 'qgis' ? |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |