zoukankan      html  css  js  c++  java
  • 在macOS下正确配置 VS Code 使用 virtualenv 里的 python 环境参数

    在macos配置好并启动 virtualenv 环境后,如何让 VS Code 使用这个环境下来编译调试 python 脚本呢?

    1.首先当然是先配置好python虚拟环境

     假定配置python的的虚拟路径如下:

      $HOMExxxenv

      ps2

         ps35

         ps36

    2.然后在vscode的工作区设置中设置如下两个配置项:

    {
        "folders": [
            {
                "path": "demo"
            }
        ],
        "settings": {
            "python.pythonPath": "/Users/xxx/env/ps36/bin/python",
            "python.venvPath": "/Users/xxx/env",
            "python.venvFolders": [
                "ps2",
                "ps35",
                "ps36"
            ]

        }
    }
    3.重新启动vs code,然后打开python工作区,然后cmd+shift+p然后输入选择Python: Select Interpreter 就可以选择 venv 了。
     

    python虚拟环境virtualenv的安装与使用


    virtualenvwrapper的安装及使用


     

    virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv

    tool.  The extensions include wrappers for creating and deleting

    virtual environments and otherwise managing your development workflow,

    making it easier to work on more than one project at a time without

    introducing conflicts in their dependencies.

     

    For more information please refer to the documentation:

     

        http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html

     

    Commands available:

     

      add2virtualenv: add directory to the import path

     

      allvirtualenv: run a command in all virtualenvs

     

      cdproject: change directory to the active project

     

      cdsitepackages: change to the site-packages directory

     

      cdvirtualenv: change to the $VIRTUAL_ENV directory

     

      cpvirtualenv: duplicate the named virtualenv to make a new one

     

      lssitepackages: list contents of the site-packages directory

     

      lsvirtualenv: list virtualenvs

     

      mkproject: create a new project directory and its associated virtualenv

     

      mktmpenv: create a temporary virtualenv

     

      mkvirtualenv: Create a new virtualenv in $WORKON_HOME

     

      rmvirtualenv: Remove a virtualenv

     

      setvirtualenvproject: associate a project directory with a virtualenv

     

      showvirtualenv: show details of a single virtualenv

     

      toggleglobalsitepackages: turn access to global site-packages on/off

     

      virtualenvwrapper: show this help message

     

      wipeenv: remove all packages installed in the current virtualenv

     

      workon: list or change working virtualenvs

     

    mkvirtualenv创建python虚拟环境

    mkvirtualenv -p <指定版本python可执行文件名>  <虚拟环境目录名>

     比如:
    使用python2.7
    mkvirtualenv -p python2.7  py27
     使用python3.7
    mkvirtualenv -p python3.7  py37
     
     
     

     

  • 相关阅读:
    备忘录模式
    中介者模式
    观察者模式、发布订阅和事件驱动
    ELK日志系统之kibana的使用操作
    ELK日志系统之说说logstash的各种配置
    03篇ELK日志系统——升级版集群之ELK日志系统整合springboot项目
    02篇ELK日志系统——升级版集群之kibana和logstash的搭建整合
    01篇ELK日志系统——升级版集群之elasticsearch集群的搭建
    Linux安装jdk环境
    01GitLab的使用——创建项目并上传到GitLab
  • 原文地址:https://www.cnblogs.com/it-tsz/p/9031771.html
Copyright © 2011-2022 走看看