我正在尝试在Linux服务器上创建虚拟环境.但是我收到以下错误:
$ virtualenv venv2
Running virtualenv with interpreter /usr/bin/python2
New python executable in /home/org/cpmf2-biotec/apps/venv2/bin/python2
Also creating executable in /home/org/cpmf2-biotec/apps/venv2/bin/python
Installing setuptools, pkg_resources, pip, wheel...
Complete output from command /home/org/cpmf2-biotec/apps/venv2/bin/python2 - setuptools pkg_resources pip wheel:
Traceback (most recent call last):
File "<stdin>", line 24, in <module>
File "/usr/share/python-wheels/pip-8.1.1-py2.py3-none-any.whl/pip/__init__.py", line 215, in main
File "/home/org/cpmf2-biotec/apps/venv2/lib/python2.7/locale.py", line 581, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting
----------------------------------------
...Installing setuptools, pkg_resources, pip, wheel...done.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/virtualenv.py", line 2363, in …Run Code Online (Sandbox Code Playgroud) 我正在使用Python Stripe包.我收到了错误Stripe no longer supports API requests made with TLS 1.0.我在Mac上使用Python 2.7.我该如何解决?
# Set this to your Stripe secret key (use your test key!)
stripe.api_key = "sk_test_VAjLc9DN9BXMS3GPvFn5W92c"
# Get the credit card details
token = info['stripeToken']
amount = info['amount']
description = info['description']
# Create the charge on Stripe's servers - this will charge the user's card
charge = stripe.Charge.create(
amount=amount,
currency="usd",
card=token,
description=description
)
Run Code Online (Sandbox Code Playgroud)
Traceback (most recent call last):
File "/Users/vertace/Desktop/payableApp-Sumup/payableAppServer.py", line 23, in pay
description=description …Run Code Online (Sandbox Code Playgroud) 我想在Jinja2 HTML页面的开头添加一行代码。我可以轻松地将其添加为其他任何元标记等,但是我只需要在一页中使用此代码,因此没有理由将其保留在网站标题中。
我尝试将其作为字符串传递给render_template,但是它没有出现在最终渲染器中。
@app.route('/page')
def page():
str = "<script src='https://site.xy/api.js'></script>"
return render_template('page.html', script_string = str)
Run Code Online (Sandbox Code Playgroud)
page.html:
{% extends "layout.html" %}
{{script_string}}
{% block content %}
Run Code Online (Sandbox Code Playgroud)
我也尝试在带有块的布局文件中执行此操作,但是它也失败了。
{% block js %}<script src='https://site.xy/api.js'></script>{% endblock %}
Run Code Online (Sandbox Code Playgroud)
如何在page.html不添加脚本标签的情况下将其添加到其他页面?
在 DynamoDB 表中,我在没有任何过滤器的情况下应用时有161712 条记录,我只收到了 10589 条扫描计数值
这是 mytable 元
{
"AttributeDefinitions": [
{
"AttributeName": "question_id",
"AttributeType": "N"
},
{
"AttributeName": "timestamp",
"AttributeType": "S"
}
],
"TableName": "users_answers",
"KeySchema": [
{
"AttributeName": "timestamp",
"KeyType": "HASH"
},
{
"AttributeName": "question_id",
"KeyType": "RANGE"
}
],
"TableStatus": "ACTIVE",
"CreationDateTime": "2017-09-12T12:33:22.615Z",
"ProvisionedThroughput": {
"LastIncreaseDateTime": "2017-09-12T16:46:26.742Z",
"NumberOfDecreasesToday": 0,
"ReadCapacityUnits": 80,
"WriteCapacityUnits": 80
},
"TableSizeBytes": 16014441,
"ItemCount": 161712
}
Run Code Online (Sandbox Code Playgroud)
当我做上面表的扫描操作时只会得到 10589 条记录
table = dynamo.get_table('answer_options')
x = table.scan()
Run Code Online (Sandbox Code Playgroud)
请建议我如何从表中获取整个记录
环境:python 3.5.1,flask dynamodb
提前致谢
我有一堆应用程序相互交互。我需要将它们部署在 Amazon Lambda 上,每个应用程序都有每个域。我正在使用 zappa 部署它们。在我部署一个之后,只是尝试部署另一个。但我收到此错误。
错误:此应用程序已部署 - 您是要调用更新吗?
看来它要更新已经部署的以前的应用程序。我不知道这个。为什么它们被识别为相同的应用程序?你有什么想法吗?如何将其部署为 Lambda 上的独立服务?
我有一个Python中的两个词典列表
list = [{'id' : 'ewsfsdf',
'_source' :
{'timestamp':'2018-08-08T20:56:01',
'bytes':'43534534'}},
{'id' : 'ewsfsdz',
'_source' :
{'timestamp':'2018-08-08T20:57:01',
'bytes':'4354343534'}}]
Run Code Online (Sandbox Code Playgroud)
我想按第二深度字典中的时间戳排序列表元素.我查找了许多其他python示例,但无法通过列表中字典元素的字典元素找到合适的解决方案来排序列表元素.
你能给我一个线索吗?
我正在尝试将我的烧瓶应用程序与mysql数据库连接。
Python版本:Python 2.7.11
我试图安装flask_mysqldb的pip install flask_mysqldb,但我得到这个错误:
Collecting flask_mysqldb
Requirement already satisfied: Flask>=0.10 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from flask_mysqldb) (1.0.2)
Collecting mysqlclient (from flask_mysqldb)
Using cached https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Requirement already satisfied: itsdangerous>=0.24 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Flask>=0.10->flask_mysqldb) (0.24)
Requirement already satisfied: Jinja2>=2.10 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Flask>=0.10->flask_mysqldb) (2.10)
Requirement already satisfied: Werkzeug>=0.14 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Flask>=0.10->flask_mysqldb) (0.14.1)
Requirement already satisfied: click>=5.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Flask>=0.10->flask_mysqldb) (6.7)
Requirement already satisfied: MarkupSafe>=0.23 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from Jinja2>=2.10->Flask>=0.10->flask_mysqldb) (1.0)
Building wheels for collected packages: mysqlclient
Running …Run Code Online (Sandbox Code Playgroud) 我正在尝试添加两个数字并将其显示在新的 html 页面中,
代码来自flask import Flask,render_template,request
app=Flask(__name__)
@app.route('/')
@app.route('/<name>')
def index(name='Priya'):
name=request.args.get('name',name)
return "I am happy,{}".format(name)
@app.route('/add/<int:num1>/<float :num2>')
@app.route('/add/<float:num1>/<float :num2>')
@app.route('/add/<int:num1>/<int :num2>')
@app.route('/add/<float:num1>/<int :num2>')
def add(num1,num2):
#return str(num1+num2)
return """
<!doctype html>
<html>
<head><title>Addition game! </title></head><body>
<h1>
{}+{} = {}</body></html>""".format(num1,num2,num1+num2)
if __name__ == '__main__':
app.run(debug=True)
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Heroku上托管的OpenCV,Flask,Face Recognition制作Web应用程序。在localhost上,一切都按预期运行,但是在Heroku上,我无法打开客户端摄像头。我知道我需要javascript或WebSocket来实现这一目标。我可以用javascript找到的所有内容是如何从浏览器上的相机中流式传输,这对我来说并不好,因为我需要打开OpenCV框架进行面部检测和识别。另外,我还在寻找WebSocket和flask-socket,但它们只发送消息,而不发送视频。
这是我的代码:app.py
'''Face Detection Login App '''
import random, string
import face_recognition
import cv2
import glob
from flask import Flask, render_template, redirect, url_for
app = Flask(__name__)
@app.route('/')
def index():
render_template('home.html')
@app.route('/article')
def article():
return render_template('article.html')
@app.route('/registered')
def registered():
return render_template('registered.html')
@app.route('/reject')
def reject():
return render_template('reject.html')
@app.route('/login', methods=["GET", "POST"])
def login():
page_name = 'reject'
video_capture = cv2.VideoCapture(0)
# Load faces
faces = 'faces/*.jpg*'
face = glob.glob(faces)
for fn in face:
try_image = face_recognition.load_image_file(f'{fn}')
print(f'{fn}')
try_face_encoding = face_recognition.face_encodings(try_image)
if not try_face_encoding: …Run Code Online (Sandbox Code Playgroud) 我正在flask中创建一个联系表单,我想在jinja2中使用html占位符,如何在jinja 2中使用html占位符?
<form action="{{ url_for('contact_page') }}" class="col-md-6 mx-auto my-auto mt-3" method="POST">
{{ form.hidden_tag() }}
<p class="text-left">{{ form.name.label() }}</p>
{{ form.name(class="form-control mb-2") }}
<p class="text-left">{{ form.email.label() }}</p>
{{ form.email(class="form-control mb-2") }}
<p class="text-left">{{ form.subject.label() }}</p>
{{ form.subject(class="form-control mb-2") }}
<p class="text-left">{{ form.message.label() }}</p>
{{ form.message(class="form-control mb-3") }}
<div class="form-group">
{{ form.submit(class="btn btn-primary btn-round mt-4 ") }}
</div>
</form>
Run Code Online (Sandbox Code Playgroud)