Tag Archives: Flask

[Solved] Pycharm Build a flash environment Error: Non zero exit code (2)

Error during installation

Analyze problems

Pycharm relies on — build dir to install packages, but this has been removed in the latest version of PIP

The PIP I use now is version 21.3.1. The solution is to reduce the PIP version of the project to PIP 21.2.4

Specific operation

1. Run CMD or windows PowerShell as administrator

2. Enter the interpreter path under the file + – M PIP install PIP = = 21.2.4

3. Open pycharm and view PIP information in project interpreter

4. Now try downloading flash

5. You should be able to display success and create a py file

6. Run it and the following web address will appear. Click to open

7. When the content appears, flash is successfully installed

An error was reported when flash DB init was running, and the init DB command could not be found

flask init-db

The result is ` error: no such command “init DB”

That’s because init DB has been replaced by flash DB init

run flask db init error

The reason is that you can’t find the app.py file in your project, so you can’t confirm that your project is a flash project

I’m here because I renamed app. Py to manage. Py

Solutions

SQLALCHEMY_ DATABASE_ Uri and Sqlalchemy_ TRACK_ Modifications configuration error

Problem solving

The error report means, sqllchemy_ DATABASE_ Uri and Sqlalchemy_ TRACK_ Modifications both are required and cannot be omitted

You need to check whether there are these two items in the settings

If it is already set in the settings, please check whether the settings are before configuring the database. The order is very important

2. mysql 1366 VARIABLE_ VALUE incorrect

2. Problem solving

If the connection engine is not configured when configuring mysql, this error will be reported

The solution is as follows

Strange frame error caused by incorrect use of flash. Redirect (‘/ path’) in flash

How is 618 sales champion made?Uncover the secret of e-commerce’s “invigorating” hundreds of millions of sales data>>>

I use the following code in the location of the home page:

import flask
@page_index.route('/')
def index():
    flask.redirect('/pythoncgi/')

Results the site has the following errors:

[11/Nov/2019 15:03:01] "GET/HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 2463, in __call__
    return self.wsgi_app(environ, start_response)
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 2449, in wsgi_app
    response = self.handle_exception(e)
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1866, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib64/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
    return self.finalize_request(rv)
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 1967, in finalize_request
    response = self.make_response(rv)
  File "/usr/local/lib64/python3.6/site-packages/flask/app.py", line 2097, in make_response
    "The view function did not return a valid response. The"
TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.

The solution is as follows:

@page_index.route('/')
def index():
    return flask.redirect('/pythoncgi/')

Error “modulenotfounderror: no module named” in installing flash in Python 3.8_ ctypes’”

Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>


I wanted to configure the flash + nginx + uwsgi environment in CentOS. As a result, there are problems in installing the most basic flash package… Here is my environment:

Server: alicloud ECS centos7

Python version: 3.8.0


Problem Description:

When executing the command “ PIP3 install flash ” to install flash, the following error occurs:

from _ctypes import Union, Structure, Array
    ModuleNotFoundError: No module named '_ctypes'

From the error description, it is missing_ Ctypes module. According to the online search results, this error mostly occurs when installing Python 3.7 or above. The solutions are as follows:

Solution to this error when installing Python:

The reason is that the package “libffi devel” is missing. You can use Yum to install it

yum install libffi-devel

— refer to “Begonia is not full”

However, for me, the problem has not been solved. I still report the same error when I execute PIP installation command again after installing libffi devel, but most people can solve it perfectly through the above methods, which can not help but cause my thinking

Thinking:

The difference between me and the above solution is that I didn’t make an error when installing Python 3.8, but after I owned Python 3.8, I made an error when installing flash

Inspired by Bryan, he installed “libffi devel” and then re installed Python to solve the problem

I didn’t make any explicit errors when installing Python 3.8. I guess it might be the optimization of Python 3.8 relative to 3.7, but the problem is still unsolved. Therefore, after installing “libffi devel”, I choose to re install Python 3.8. For the installation process, please refer to here

The problem has finally been solved. Long live the reload

Solve the problem of “typeerror: ‘bool’ object is not callable” in flash and Django

> Welcome to Flask’s large tutorial project! When it comes time to refactor the user model, run the script and it says :

TypeError: ‘bool’ object is not callable

This is the user model:

class User(db.Model):
    id = db.Column(db.Integer, primary_key=True) nickname = db.Column(db.String(64), index=True, unique=True) email = db.Column(db.String(120), index=True, unique=True) posts = db.relationship('Post', backref='author', lazy='dynamic')  @property def is_authenticated(self): return True  @property def is_active(self): return True  @property def is_anonymous(self): return False def get_id(self): try: return unicode(self.id) # python 2 except NameError: return str(self.id) # python 3 def __repr__(self): return '<User %r>' % (self.nickname) 

This is the code at the time of the call:

from flask import render_template, flash, redirect, session, url_for, request, g
from flask.ext.login import login_user, logout_user, current_user, login_required
from app import app, db, lm, oid from .forms import LoginForm from .models import User @app.route('/login', methods=['GET', 'POST']) @oid.loginhandler def login(): if g.user is not None and g.user.is_authenticated(): # error return redirect(url_for('index')) form = LoginForm() if form.validate_on_submit(): session['remember_me'] = form.remember_me.data return oid.try_login(form.openid.data, ask_for=['nickname', 'email']) return render_template('login.html', title='Sign In', form=form, providers=app.config['OPENID_PROVIDERS']) 

is_authenticated is a property, not a method, as described in Resources, so just remove the parentheses. There are two typos in this section of the book. Please refer to the Git source code.

put the wrong place:
if g.user is not None and g.user.is_authenticated():
if g.user is not None and G.user. is_authenticated:
and then no error.