我在 Flask 应用程序中收到此错误:
curl http://0.0.0.0:8080/ -H "Authorization: Bearer TGazPL9rf3aIftplCYDTGDc8cbTd"
{
"msg": "Not enough segments"
}
Run Code Online (Sandbox Code Playgroud)
这是一个示例:
from flask import Flask
from flask_restful import Resource, Api
from flask_jwt_extended import JWTManager, jwt_required
app = Flask(__name__)
jwt = JWTManager(app)
api = Api(app)
class HelloWorld(Resource):
@jwt_required
def get(self):
return {'hello': 'world'}
api.add_resource(HelloWorld, '/')
Run Code Online (Sandbox Code Playgroud)
安慰:
* Serving Flask app "app.py" (lazy loading)
* Environment: development
* Debug mode: on
* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active! …Run Code Online (Sandbox Code Playgroud) 使用Artifactory(https://cloud.google.com/artifact-registry)我打算添加对诗歌的依赖(https://python-poetry.org/docs/repositories/)。
我可以使用命令安装:(pip install --index-url https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/ <PACKAGE_NAME>使用 keyrings.google-artifactregistry-auth 进行身份验证)
我打算使用 POETRY 来管理我的依赖项。我不知道使用诗歌是否会增加这种依赖性。poetry add --source <PACKAGE_NAME> https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>我收到此错误:
poetry update
Updating dependencies
Resolving dependencies... (0.9s)
RepositoryError
401 Client Error: Unauthorized for url: https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/pytest/
Run Code Online (Sandbox Code Playgroud)
我的 pyproject.toml
...
[[tool.poetry.source]]
name = "SOME_LIB"
url = " https://us-central1-python.pkg.dev/<PROJECT_ID>/<SOME_LIB_REPO>/simple/"
secondary = true
Run Code Online (Sandbox Code Playgroud)
这里有如何使用 PIP/VIRTUALENV 进行配置的详细信息:https://cloud.google.com/artifact-registry/docs/python/authentication但没有有关 Poetry 的详细信息。
您对此有什么建议吗?
python python-packaging python-poetry google-artifact-registry
请帮助如何解决此错误 - AttributeError(key):
File "pivot_table_measurements.py", line 1, in <module>
from database import *
File "/home/dedeco/Projetos/bigclima-project/database.py", line 24, in <module>
MeasureRanges = Base.classes.measure_ranges
File "/home/dedeco/craw/lib/python3.5/site-packages/sqlalchemy/util/_collections.py", line 212, in __getattr__
raise AttributeError(key)
AttributeError: measure_ranges
Run Code Online (Sandbox Code Playgroud)
数据库.py:
from sqlalchemy.ext.automap import automap_base
from sqlalchemy.orm import Session
from sqlalchemy import create_engine
from sqlalchemy.orm.exc import MultipleResultsFound, NoResultFound
import string
from decimal import Decimal
ECHO = False
AUTOFLUSH = False
Base = automap_base()
engine = create_engine('postgresql://user:pass@localhost:5432/clima', echo=ECHO)
Base.prepare(engine, reflect=True)
Country = Base.classes.countries
State = Base.classes.states
City = Base.classes.cities …Run Code Online (Sandbox Code Playgroud) 我想改进我的代码,替换这个:
workbook = xlwt.Workbook()
sheet = workbook.add_sheet("WS")
header = [u'Nome da estação',u'Altitude',u'Latitude',u'Longitude']
column =0
for h in header:
sheet.write(0, column, h)
column += 1
Run Code Online (Sandbox Code Playgroud)
对于某些代码直接使用数组头来写一整行。任何的想法?
我正在尝试在我的virtualenv中安装FuzzySet:
(virtualenv) machine:user$ pip install FuzzySet
Run Code Online (Sandbox Code Playgroud)
我收到了这个错误:
(virtualenv) machine:user$ pip install FuzzySet
Collecting FuzzySet
Using cached fuzzyset-0.0.11.tar.gz
Requirement already satisfied: python-levenshtein in /Users/dedeco/Envs/Craw/lib/python3.6/site-packages (from FuzzySet)
Requirement already satisfied: texttable in /Users/dedeco/Envs/Craw/lib/python3.6/site-packages (from FuzzySet)
Requirement already satisfied: setuptools in /Users/dedeco/Envs/Craw/lib/python3.6/site-packages (from python-levenshtein->FuzzySet)
Building wheels for collected packages: FuzzySet
Running setup.py bdist_wheel for FuzzySet ... error
Complete output from command /Users/dedeco/Envs/Craw/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/y7/1vddc8q51zq_q_dc0gw581480000gn/T/pip-build-1e0boni3/FuzzySet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/y7/1vddc8q51zq_q_dc0gw581480000gn/T/tmpbguw98h6pip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py …Run Code Online (Sandbox Code Playgroud)