lnlidawei

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

[ubuntu2504]  python venv (flask+sqlite/mariadb+sqlalchemy+gunicorn+gevent)

 

 

 

 

一、创建虚拟环境的脚本(python)

[wit@ubuntu:venv]$ cat create_venv 
#!/usr/bin/bash




function config_env()
{
  # install plugins in ubuntu2504
  # this plugin for python -m venv
  sudo apt install python3-venv

  # this plugins for mariadb; 
  # finally for pip install mariadb
  sudo apt install libmariadb3 libmariadb-dev
}




function create_config_venv()
{
  venv_name=$1

  # create venv_name
  python3 -m venv ${venv_name}
  cd ${venv_name}
  source bin/activate

  # upgrade pip
  pip install --upgrade pip

  # install plugins
  pip install mariadb
  pip install flask
  pip install sqlalchemy
  pip install gunicorn
  pip install gevent

  # exit venv_name
  deactivate
}




create_config_venv $1


[wit@ubuntu:venv]$ 

 

 

二、脚本应用

[wit@ubuntu:venv]$ cat create_venv 
#!/usr/bin/bash




function config_env()
{
  # install plugins in ubuntu2504
  # this plugin for python -m venv
  sudo apt install python3-venv

  # this plugins for mariadb; 
  # finally for pip install mariadb
  sudo apt install libmariadb3 libmariadb-dev
}




function create_config_venv()
{
  venv_name=$1

  # create venv_name
  python3 -m venv ${venv_name}
  cd ${venv_name}
  source bin/activate

  # upgrade pip
  pip install --upgrade pip

  # install plugins
  pip install mariadb
  pip install flask
  pip install sqlalchemy
  pip install gunicorn
  pip install gevent

  # exit venv_name
  deactivate
}




create_config_venv $1


[wit@ubuntu:venv]$ 
[wit@ubuntu:venv]$ 
[wit@ubuntu:venv]$ ./create_venv test_venv
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Requirement already satisfied: pip in ./lib/python3.13/site-packages (25.0)
Collecting pip
  Using cached https://mirrors.aliyun.com/pypi/packages/29/a2/d40fb2460e883eca5199c62cfc2463fd261f760556ae6290f88488c362c0/pip-25.1.1-py3-none-any.whl (1.8 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 25.0
    Uninstalling pip-25.0:
      Successfully uninstalled pip-25.0
Successfully installed pip-25.1.1
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting mariadb
  Using cached mariadb-1.1.12-cp313-cp313-linux_x86_64.whl
Collecting packaging (from mariadb)
  Using cached https://mirrors.aliyun.com/pypi/packages/20/12/38679034af332785aac8774540895e234f4d07f7545804097de4b666afd8/packaging-25.0-py3-none-any.whl (66 kB)
Installing collected packages: packaging, mariadb
Successfully installed mariadb-1.1.12 packaging-25.0
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting flask
  Using cached https://mirrors.aliyun.com/pypi/packages/3d/68/9d4508e893976286d2ead7f8f571314af6c2037af34853a30fd769c02e9d/flask-3.1.1-py3-none-any.whl (103 kB)
Collecting blinker>=1.9.0 (from flask)
  Using cached https://mirrors.aliyun.com/pypi/packages/10/cb/f2ad4230dc2eb1a74edf38f1a38b9b52277f75bef262d8908e60d957e13c/blinker-1.9.0-py3-none-any.whl (8.5 kB)
Collecting click>=8.1.3 (from flask)
  Using cached https://mirrors.aliyun.com/pypi/packages/85/32/10bb5764d90a8eee674e9dc6f4db6a0ab47c8c4d0d83c27f7c39ac415a4d/click-8.2.1-py3-none-any.whl (102 kB)
Collecting itsdangerous>=2.2.0 (from flask)
  Using cached https://mirrors.aliyun.com/pypi/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl (16 kB)
Collecting jinja2>=3.1.2 (from flask)
  Using cached https://mirrors.aliyun.com/pypi/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl (134 kB)
Collecting markupsafe>=2.1.1 (from flask)
  Using cached https://mirrors.aliyun.com/pypi/packages/0c/91/96cf928db8236f1bfab6ce15ad070dfdd02ed88261c2afafd4b43575e9e9/MarkupSafe-3.0.2-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (23 kB)
Collecting werkzeug>=3.1.0 (from flask)
  Using cached https://mirrors.aliyun.com/pypi/packages/52/24/ab44c871b0f07f491e5d2ad12c9bd7358e527510618cb1b803a88e986db1/werkzeug-3.1.3-py3-none-any.whl (224 kB)
Installing collected packages: markupsafe, itsdangerous, click, blinker, werkzeug, jinja2, flask
Successfully installed blinker-1.9.0 click-8.2.1 flask-3.1.1 itsdangerous-2.2.0 jinja2-3.1.6 markupsafe-3.0.2 werkzeug-3.1.3
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting sqlalchemy
  Using cached https://mirrors.aliyun.com/pypi/packages/5e/51/5ba9ea3246ea068630acf35a6ba0d181e99f1af1afd17e159eac7e8bc2b8/sqlalchemy-2.0.41-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB)
Collecting greenlet>=1 (from sqlalchemy)
  Using cached https://mirrors.aliyun.com/pypi/packages/26/f2/ad51331a157c7015c675702e2d5230c243695c788f8f75feba1af32b3617/greenlet-3.2.3-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (608 kB)
Collecting typing-extensions>=4.6.0 (from sqlalchemy)
  Downloading https://mirrors.aliyun.com/pypi/packages/69/e0/552843e0d356fbb5256d21449fa957fa4eff3bbc135a74a691ee70c7c5da/typing_extensions-4.14.0-py3-none-any.whl (43 kB)
Installing collected packages: typing-extensions, greenlet, sqlalchemy
Successfully installed greenlet-3.2.3 sqlalchemy-2.0.41 typing-extensions-4.14.0
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting gunicorn
  Using cached https://mirrors.aliyun.com/pypi/packages/cb/7d/6dac2a6e1eba33ee43f318edbed4ff29151a49b5d37f080aad1e6469bca4/gunicorn-23.0.0-py3-none-any.whl (85 kB)
Requirement already satisfied: packaging in ./lib/python3.13/site-packages (from gunicorn) (25.0)
Installing collected packages: gunicorn
Successfully installed gunicorn-23.0.0
Looking in indexes: http://mirrors.aliyun.com/pypi/simple/
Collecting gevent
  Using cached https://mirrors.aliyun.com/pypi/packages/00/5c/bfefe3822bbca5b83bfad256c82251b3f5be13d52d14e17a786847b9b625/gevent-25.5.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)
Requirement already satisfied: greenlet>=3.2.2 in ./lib/python3.13/site-packages (from gevent) (3.2.3)
Collecting zope.event (from gevent)
  Using cached https://mirrors.aliyun.com/pypi/packages/fe/42/f8dbc2b9ad59e927940325a22d6d3931d630c3644dae7e2369ef5d9ba230/zope.event-5.0-py3-none-any.whl (6.8 kB)
Collecting zope.interface (from gevent)
  Using cached https://mirrors.aliyun.com/pypi/packages/b6/66/ac05b741c2129fdf668b85631d2268421c5cd1a9ff99be1674371139d665/zope.interface-7.2-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (264 kB)
Collecting setuptools (from zope.event->gevent)
  Using cached https://mirrors.aliyun.com/pypi/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl (1.2 MB)
Installing collected packages: setuptools, zope.interface, zope.event, gevent
Successfully installed gevent-25.5.1 setuptools-80.9.0 zope.event-5.0 zope.interface-7.2
[wit@ubuntu:venv]$ 

 

 

三、参考资料

 

  1、  pip  --  https://pip.pypa.io/en/stable/user_guide/

 

posted on 2025-06-09 14:42  lnlidawei  阅读(26)  评论(0)    收藏  举报