到目前为止,我还不知道如何解决以下问题:
我在Windows 8.1下安装了Python 3。除了这个Python安装之外,我还有其他几个随QGIS和ArcGIS Pro等程序一起安装的程序。这些程序在它们的程序文件夹中有自己的Python安装和Python可执行文件。
现在我有了一个Python脚本,它依赖于为QGIS Python安装的一些模块。我想从命令行(或从R中)运行脚本。但是,脚本将由我的没有模块的主Python安装来处理。
我尝试添加一些路径到PATH和PYTHONPATH变量,但这只会导致我的Python IDE (Spyder)不再启动。
路径:
C:\Users\Manuel\Python\Scripts\;C:\Users\Manuel\Python\;C:\Users\Manuel\AppData\Local\Programs\Python\Launcher\;C:\Users\Manuel\AppData\Roaming\TinyTeX\bin\win32;C:\Perl64\site\bin;C:\Perl64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\IBM\SPSS\Statistics\24\JRE\bin;D:\x2go\PuTTY\;C:\Program Files (x86)\Common Files\Ulead Systems\MPEG;C:\Program Files;C:\Program Files\snap\bin;C:\Program Files\Inkscape\bin;D:\Program_Files\gdal\bin;C:\Users\Manuel\AppData\Local\GitHubDesktop\bin
PYTHONPATH:
C:\Program Files\Spyder\pkgs;C:\Users\Manuel;C:\Program Files\QGIS 3.14.16\apps\qgis\python\plugins;C:\Program Files\QGIS 3.14.16\apps\qgis\python;C:\Program Files\QGIS 3.14.16\apps\Python37
我还尝试将命令提示符中的"py“替换为C:\Programme\QGIS3.14.16\bin\python3.exe,同样不起作用(错误:访问被拒绝)。
我尝试了this教程在python中导入模块,它提供了
ImportError: DLL load failed while importing _core: Module not found
在这种情况下,我如何告诉命令提示符使用特定的Python安装(我希望在所有其他情况下使用其他Python安装)?
发布于 2021-09-15 12:29:31
我会做你尝试过的事情:"I also tried to replace "py" in the command prompt with the entire path to the QGIS Python exe, which also didn't work (Error: Access denied).
“
但请尝试以管理员权限在powershell中运行它。
https://stackoverflow.com/questions/69192521
复制相似问题