gpt4 book ai didi

python-3.x - 没有名为 'urlparse' 的模块,但我没有使用 urlparse

转载 作者:行者123 更新时间:2023-12-03 15:33:07 28 4
gpt4 key购买 nike

我试图弄清楚为什么我会看到错误 ModuleNotFoundError: No module named 'urlparse'但我从不在我的代码中调用 urlparse。当我尝试使用 pip 安装 urlparse 时,我看到该模块不存在。当我尝试使用 pip 安装 urllib.parse 时,我看到与 urllib.parse 相同的消息。 No matching distribution found for urllib.parse .

我在这里想念什么?

from flask import Flask, request, redirect, url_for, session, g, flash, \
render_template
from flask_oauth import OAuth

from sqlalchemy import create_engine, Column, Integer, String
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base

# configuration
SECRET_KEY = 'development key'
DEBUG = True

# setup flask
app = Flask(__name__)
app.debug = DEBUG
app.secret_key = SECRET_KEY
oauth = OAuth()

# Use Twitter as example remote app
twitter = oauth.remote_app('twitter',
base_url='https://api.twitter.com/1/',
request_token_url='https://api.twitter.com/oauth/request_token',
access_token_url='https://api.twitter.com/oauth/access_token',
authorize_url='https://api.twitter.com/oauth/authenticate',
consumer_key='',
consumer_secret=''
)


@twitter.tokengetter
def get_twitter_token(token=None):
return session.get('twitter_token')


@app.route('/')
def index():
access_token = session.get('access_token')
if access_token is None:
return redirect(url_for('login'))
access_token = access_token[0]
return render_template('templates/index.html')
if __name__ == '__main__':
app.run()

最佳答案

对于我用过的python3
from urllib.parse import urlparse
而不是 from urlparse import parse_qsl, urlparse它有效

推荐文档:https://docs.python.org/3/library/urllib.parse.html

关于python-3.x - 没有名为 'urlparse' 的模块,但我没有使用 urlparse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50146520/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com