当前位置: 首页 > 知识库问答 >
问题:

没有命名为CPIPCOG2的模块和请求

王声
2023-03-14

我运行QGIS在Mac(塞拉利昂),但我不能加载处理插件,因为这个错误:

>>> Couldn't load plugin 'processing' 
ImportError: No module named psycopg2 
Traceback (most recent call last):
  File .     "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 308, in loadPlugin
__import__(packageName)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/__init__.py", line 29, in 
from processing.tools.general import *              # NOQA
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/tools/general.py", line 31, in 
from processing.core.Processing import Processing
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/Processing.py", line 42, in 
from processing.script.ScriptUtils import ScriptUtils
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/script/ScriptUtils.py", line 30, in 
from processing.script.ScriptAlgorithm import ScriptAlgorithm
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/script/ScriptAlgorithm.py", line 33, in 
from processing.core.GeoAlgorithm import GeoAlgorithm
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/GeoAlgorithm.py", line 41, in 
from processing.core.parameters import ParameterRaster, ParameterVector, ParameterMultipleInput, ParameterTable, Parameter
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/core/parameters.py", line 32, in 
from processing.tools.vector import resolveFieldIndex
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/plugins/processing/tools/vector.py", line 35, in 
import psycopg2
  File "/usr/local/Cellar/qgis2/2.18.21/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 607, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named psycopg2
Python version: 2.7.15 (default, Jul  2 2018, 01:42:08) [GCC 4.2.1 
Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)] 
QGIS version: 2.18.21 Las Palmas, exported 

A从该链接中找到了类似的帖子:

[链接到上一篇文章](导入错误:没有模块命名请求)

在python窗口中键入导入请求导入psycopg2时,我没有收到任何错误:

你知道为什么会这样吗?我将感谢任何帮助。

共有2个答案

须旭
2023-03-14

尝试安装那些软件包

pip install psycopg2-binary requests
漆雕疏珂
2023-03-14

由于您的计算机上可以安装各种版本的Python,因此要确保pip install psycopg2二进制请求真正应用于QGIS Python环境并不总是那么简单。

您可能更喜欢从QGIS Python控制台安装软件包,执行以下操作:

from pip._internal import main as pipmain

pipmain(['install', 'psycopg2-binary', 'requests'])

 类似资料:
  • 当我尝试从python终端导入我得到这个错误,虽然我按照所有的步骤来安装xgboop,不知何故python是无法获得包的详细信息。我是相对较新的python,我可以很容易地安装Numpy和熊猫包,我使用这个链接在MACOSX上安装http://xgboost.readthedocs.io/en/latest/build.html 当我做pip安装xgboop,我得到这个错误, 我在打印系统路径上得

  • 我正在尝试使用(https://github.com/aleju/imgaug)我已使用以下命令成功安装了它: 命令的输出: 下载/解包githttps://github.com/aleju/imgaug 克隆https://github.com/aleju/imgaug 运行setup.py的/tmp/pip-PsA5jC-build(路径:/tmp/pip-PsA5jC-build/setup

  • 我在Python中工作,使用Flask。当我在我的计算机上运行我的主Python文件时,它工作得很好,但当我激活venv并在终端中运行Flask Python文件时,该文件显示我的主文件有“No Module Named bs4”。任何评论或建议都非常感谢。

  • 你好,我相信你可以帮助我的问题。我用的是Windows10,64bit.我运行下面的代码在spyder。但是存在"ModuleNotFoundError: No模块名为'tensorflow_core.estimator'"的错误。我卸载了拉伸流,拉伸板,拉伸流估计器,然后再次安装,但错误并没有消失。请问怎么解决? 代码:导入时间导入熊猫为pd导入Numpy为np导入matplotlib.pypl

  • 我在VSCode中运行我的脚本时遇到了问题。 我尝试了以下方法: 通过,和重新安装请求 直接在Python解释器中导入 这让我相信VSCode没有使用实际安装了包的正确解释器。