PyCharm使用pipenv创建虚拟环境

安装pipenv

  • pip install pipenv

创建项目目录

  • mkdir myproject

  • cd myproject

  • pipenv install # 创建虚拟环境

    To activate this project's virtualenv, run pipenv shell. Alternatively, run a command inside the virtualenv with pipenv run.

  • pipenv shell # 进入新环境

  • pipenv --venv

C:UsersAdministrator.virtualenvsfisher-susCSosD

  • pipenv install flask # 安装第三方包

  • pipenv uninstall flask # 卸载第三方包

  • exit # 退出

配置PyCharm使用pipenv环境

  • 启动PyCharm,打开名称为myproject的项目

  • 进入项目设置,搜索Project Interpreter

  • 在Project Interpreter的右上角配置按钮上选择Add Local

  • 选择VirtualEnv Environment

  • 复制刚才的环境路径"C:UsersAdministrator.virtualenvsfisher-susCSosDScriptspython.exe"到粘贴板,粘贴到existing environment的interpreter下面,点击确定。

  • 这样,就可以在PyCharm里用为myproject专门创建的python环境了。

 

原文地址:https://www.cnblogs.com/abclife/p/14930538.html