Until you install Python with pythonbrew and run Flask on a WSGI server

First note

Suddenly I don't use pythonbrew anymore. There are some reasons

pythonbrew wasn't maintained anymore

Is it pythonz now? If you want to install multiple versions, you should use pythonz. But I'm not using pythonz right now.

I didn't need multiple versions in the first place

Occasionally, I switch between 2 and 3 due to the library's convenience, so I can do it without using an external tool. The Mac has 2 series, and it is enough to add 3 series such as brew.

When I need more than one version, I wonder if it's about testing to publish something, but I can do that with Travis CI or something.

I didn't want to switch versions, I just didn't want to pollute the environment

When I think about it, the only thing I often used with pythonbrew was to create a virtual environment. That's venv. So, I settled down on my machine by simply creating an environment with venv. usually! So far, I have no problems. The law of good is that everyone is good.

http://methane.hatenablog.jp/entry/2013/11/05/Mac_%E3%81%A7_Python_%E3%81%AE%E9%96%8B%E7%99%BA%E7%92%B0%E5%A2%83%E6%A7%8B%E7%AF%89(2013_11)

Postscript is over.

Installation

pythonbrew put

$ git clone https://github.com/utahta/pythonbrew
$ ./pythonbrew-install

Pass through

$ vi ~/.bashrc
source $HOME/.pythonbrew/etc/bashrc
#If you enter it as root, it may be this one ~ ↓ ↓ ↓
source /usr/local/pythonbrew/etc/bashrc

Rereading .bashrc, you can use pythonbrew or pybrew command

Put python

#Take the plunge and use v3!
$ pybrew install 3.3.0
$ pybrew venv create testenv -p 3.3.0 #testenv is optional
$ pybrew install --framework 3.3.0  #For mac

use

$ pybrew venv use testenv  
$ python --version
Python 3.3.0 #Hooray

Put various

#In the state of using something with pybrew
$ pip install Flask
$ pip install WTForms
$ pip install sqlalchemy
$ pip install psycopg2 #For PostgreSQL
$ pip install flask-mail
$ pip install Flask-Script
$ pip install Beaker #Session management
$ pip install uwsgi

Simple app

hello.py


# coding=utf-8
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello'

@app.route('/indo')
def hello_world_indo():
    return 'नमस्ते'

if __name__ == '__main__':
    app.run(host='0.0.0.0',debug=True)

Start-up

$ python hello.py

http://[サーバのIP]:5000 You can see it in. Yay.

Launch from uWSGI

During development, start up normally without using uWSGI as before, and in the production environment, it feels like nginx + uWSGI + Flask. This time, I just tried something like "Isn't it really possible to start using uWSGI?"

$ uwsgi --http :9090  --python-path /var/app/testpy -w hello:app 

http://[サーバのIP]:9090 You can see it in.

This may not be enough to make a startup script. This is the version that works anytime.

$ /usr/local/pythonbrew/venvs/Python-3.3.0/testenv/bin/uwsgi --http :9090 -H /usr/local/pythonbrew/venvs/Python-3.3.0/testenv --python-path /var/app/testpy -w hello:app 

http://[サーバのIP]:9090 You can see it in.

Dissolution!

Recommended Posts

Until you install Python with pythonbrew and run Flask on a WSGI server
Until you create a machine learning environment with Python on Windows 7 and run it
Launch a web server with Python and Flask
Until you install and run matplotlib
Until you can install blender and run it with python for the time being
Build a detonation velocity website with Cloud Run and Python (Flask)
A memo with Python2.7 and Python3 on CentOS
Run python wsgi server on NGINX Unit
Install the python module with pip on a server without root privileges
Rock-paper-scissors with Python Let's run on a Windows local server for beginners
Install Python3 and Django on Amazon Linux (EC2) and run your web server
Until you install Caffe and run the sample
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Until you use PhantomJS with Python on Heroku
Put Docker in Windows Home and run a simple web server with Python
Until you publish a web service on GCP while studying JQuery and Python
Install selenium on Mac and try it with python
Until you install Gauge and run the official sample
A server that echoes data POSTed with flask / python
Install django on python + anaconda and start the server
Install Python and Flask (Windows 10)
[CGI] Run the Python program on the server with Vue.js + axios and get the output data
Until you run a Flask application on Google App Engine for the time being
Until you create Python Virtualenv on Windows and launch Jupyter
Until you can install your own Python library with pip
Library for specifying a name server and dig with python
Install Python 2.7.9 and Python 3.4.x with pip.
Install Python3 on Sakura server (FreeBSD)
Install and run dropbox on Ubuntu 20.04
Creating a Flask server with Docker
Run a Linux server on GCP
Run TensorFlow2 on a VPS server
A note on what you did to use Flycheck with Python
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Install mecab on Sakura shared server and call it from python
Build a Python environment on your Mac with Anaconda and PyCharm
I made a Nyanko tweet form with Python, Flask and Heroku
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
Install lp_solve on Mac OS X and call it with python.
Until you install Apache and Tomcat on Linux (CentOS) and deploy Java apps
Install Python as a Framework with pyenv
Deploy a Python app on Google App Engine and integrate it with GitHub
[Python] Run Flask on Google App Engine
Map rent information on a map with python
scipy stumbles with pip install on python 2.7.8
Until you install your own Python library
Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
Run Python code on A2019 Community Edition
Until you publish (deploy) a web application made with bottle on Heroku
Run a Python web application with Docker
Install Python3 on mixhost server [Currently NG]
Install pyenv and Python 3.6.8 on Ubuntu 18.04 LTS
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
Until you install Arch Linux on VMware
Run Jupyter notebook on a remote server
Until you can use opencv with python
[ES Lab] I tried to develop a WEB application with Python and Flask ②
Until you create an Ubuntu boot USB on your Macbook and install Ubuntu on your Thinkpad
Build a flask app made with tensorflow and dlib to work on centos7
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
Install Windows 10 from a Linux server with PXE