宗次郎の故郷

导航

Flask学习记录-pipenv虚拟环境搭建

python环境

$ python -V
Python 3.9.18
1.安装pipenv $ pip install pipenv -i https://pypi.tuna.tsinghua.edu.cn/simple $ pipenv --version pipenv, version 2023.12.1
2.创建虚拟环境 [ flask-test1]$ pipenv install Creating a virtualenv for this project... Pipfile: /usr/dog/flask_web/flask-test1/Pipfile Using default python from /usr/bin/python3 (3.9.18) to create virtualenv... ⠦ Creating virtual environment...created virtual environment CPython3.9.18.final.0-64 in 423ms creator CPython3Posix(dest=/usr/dog/.local/share/virtualenvs/flask-test1-VWpTGuDs, clear=False, no_vcs_ignore=False, global=False) seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/usr/dog/.local/share/virtualenv) added seed packages: pip==24.0, setuptools==69.1.0, wheel==0.42.0 activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator ✔ Successfully created virtual environment! Virtualenv location: /usr/dog/.local/share/virtualenvs/flask-test1-VWpTGuDs Creating a Pipfile for this project... Pipfile.lock not found, creating... Locking [packages] dependencies... Locking [dev-packages] dependencies... Updated Pipfile.lock (a36a5392bb1e8bbc06bfaa0761e52593cf2d83b486696bf54667ba8da616c839)! Installing dependencies from Pipfile.lock (16c839)... To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run.
3.激活虚拟环境 [ flask
-test1]$ pipenv shell Launching subshell in virtual environment... [dog@iZfkm309huj7srZ flask-test1]$ . /usr/dog/.local/share/virtualenvs/flask-test1-VWpTGuDs/bin/activate (flask-test1) [ flask-test1]$ pip list Package Version ---------- ------- pip 24.0 setuptools 69.1.0 wheel 0.42.0 4.退出虚拟环境 (flask-test1) [ flask-test1]$ exit exit [ flask-test1]$ pipenv -h Usage: pipenv [OPTIONS] COMMAND [ARGS]... Options: --where Output project home information. --venv Output virtualenv information. --py Output Python interpreter information. --envs Output Environment Variable options. --rm Remove the virtualenv. --bare Minimal output. --man Display manpage. --support Output diagnostic information for use in GitHub issues. --site-packages / --no-site-packages Enable site-packages for the virtualenv. [env var: PIPENV_SITE_PACKAGES] --python TEXT Specify which version of Python virtualenv should use. --clear Clears caches (pipenv, pip). [env var: PIPENV_CLEAR] -q, --quiet Quiet mode. -v, --verbose Verbose mode. --pypi-mirror TEXT Specify a PyPI mirror. --version Show the version and exit. -h, --help Show this message and exit. Usage Examples: Create a new project using Python 3.7, specifically: $ pipenv --python 3.7 Remove project virtualenv (inferred from current directory): $ pipenv --rm Install all dependencies for a project (including dev): $ pipenv install --dev Create a lockfile containing pre-releases: $ pipenv lock --pre Show a graph of your installed dependencies: $ pipenv graph Check your installed dependencies for security vulnerabilities: $ pipenv check Install a local setup.py into your virtual environment/Pipfile: $ pipenv install -e . Use a lower-level pip command: $ pipenv run pip freeze Commands: check Checks for PyUp Safety security vulnerabilities and against PEP 508 markers provided in Pipfile. clean Uninstalls all packages not specified in Pipfile.lock. graph Displays currently-installed dependency graph information. install Installs provided packages and adds them to Pipfile, or (if no packages are given), installs all packages from Pipfile. lock Generates Pipfile.lock. open View a given module in your editor. requirements Generate a requirements.txt from Pipfile.lock. run Spawns a command installed into the virtualenv. scripts Lists scripts in current environment config. shell Spawns a shell within the virtualenv. sync Installs all packages specified in Pipfile.lock. uninstall Uninstalls a provided package and removes it from Pipfile. update Runs lock, then sync. upgrade Resolves provided packages and adds them to Pipfile, or (if no packages are given), merges results to Pipfile.lock verify Verify the hash in Pipfile.lock is up-to-date.

 

posted on 2024-03-27 22:46  宗次郎  阅读(17)  评论(0编辑  收藏  举报