简体   繁体   English

无法导入 six.moves 模块

[英]can't import six.moves module

import json

from six.moves.urllib_parse import urlencode
from six.moves.urllib_request import urlopen
from django.core.management.base import CommandError


def call(method, data, post=False):
    """
    Calls `method` from the DISQUS API with data either in POST or GET.
    Returns deserialized JSON response.
    """
    url = "%s%s" % ("http://disqus.com/api/", method)
    if post:
        # POST request
        url += "/"
        data = urlencode(data)
    else:
        # GET request
        url += "?%s" % urlencode(data)
        data = ""
    res = json.load(urlopen(url, data))
    if not res["succeeded"]:
        raise CommandError(
            "'%s' failed: %s\nData: %s" % (method, res["code"], data)
        )
    return res["message"]

module) moves模块)移动
Import "six.moves.urllib_parse" could not be resolved from sourcePylancereportMissingModuleSource无法从 sourcePylancereportMissingModuleSource 解析导入“six.moves.urllib_parse”

installed the six module to Python virtual environment将六个模块安装到 Python 虚拟环境

six can be imported without problems,六个可以毫无问题地导入,
Occurs from six.moves MissingModuleSource发生在 six.moves MissingModuleSource

Why can't Import?为什么不能导入? six.moves六步

try changing system interpreter path of python in your IDE and set it to the virtual environment you use, in which you have installed the module.尝试更改 IDE 中 python 的系统解释器路径,并将其设置为您使用的虚拟环境,您已经在其中安装了该模块。

an example in vscode vscode中的一个例子

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

相关问题 来自 six.moves import urllib ImportError: No module named six.moves - from six.moves import urllib ImportError: No module named six.moves 相对导入“ six.moves.urllib”,应为“ six.moves” - Relative import 'six.moves.urllib', should be 'six.moves' Google API Python 客户端:“从六个.moves 导入 zip 导入错误:没有名为移动的模块” - Google API Python Client: "from six.moves import zip ImportError: No module named moves" Google App Engine:从six.moves导入http_client,没有名为moves的模块 - Google App Engine: from six.moves import http_client no module named moves 预安全导入模块挂钩后的 PyInstaller 最大递归错误 [six.moves] - PyInstaller maximum recursion error after pre-safe import module hook [six.moves] `from six.moves import urllib` 在 Python 中做什么? - What does `from six.moves import urllib` do in Python? 模块“six.moves”没有属性“collections_abc” - module 'six.moves' has no attribute 'collections_abc' Linux Python Scrapy 没有名为 Six.moves 的模块 - Linux Python Scrapy No module named six.moves 安装错误:无法从“six.moves”(未知位置)导入名称“collections_abc” - installation error: cannot import name 'collections_abc' from 'six.moves' (unknown location) 无法在python 2.7中导入six.moves.xmlrpc_client - can't import six.moves.xmlrpc_client in python 2.7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM