美文网首页
Python 环境安装

Python 环境安装

作者: tevorwang | 来源:发表于2021-09-08 09:13 被阅读0次

环境安装

  • macOS 上安装 python

    • 自动安装方式一 -- homebrew

      brew install python 
      # 然后安装提示,中心配置环境变量,将 python 添加到 PATH
      
  • 自动安装二 (使用 pyenv,此方法可以在以后方便安装其他版本的 python)

    brew install pyenv   # 安装 python 版本管理工具(类似于nvm、rvm、jenv)
    
    pyenv install 3.8-dev  # 安装 python 3.8
    pyenv global 3.8-dev   # 配置默认 python 版本
    pyenv init  # 执行 init 命令,按照提示加载 pyenv 到 shell
    
    # 如果使用的是bash,请将代码添加到 ~/.profile
    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    # 在 ~/.bashrc 中加载pyenv
    eval "$(pyenv init -)"
    
    # 如果是zsh,请将代码添加到 ~/.profile 和 ~/.zprofile 文件
    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    # 在 ~/.zshrc 文件中加载pyenv
    eval "$(pyenv init -)"
    
    
  • 手动安装

    打开 python 官网,点击下载链接 https://www.python.org/downloads/,找到下载按钮,下载安装包安装即可。

  • Windows

    • scoop自动安装

      scoop install python    # 就这么简单
      

IDE

  • Visual Studio Code (推荐)

    • macOS

      • 点击下载链接,然后选择自己的系统版本下载安装,解压后拖进 Applicaitons文件夹即可

      • 使用 homebrew 安装

         brew install --cask visual-studio-code
        
    • Windows

      点击下载链接,然后选择自己的系统版本下载安装

    • vscode 配置

      1. 新建一个文件,编辑器点击最后下角 plain text

        Screen Shot 2021-09-07 at 8.58.11 PM.png
      2. 在弹出窗口中,输入 python 然后回车

      Screen Shot 2021-09-07 at 8.58.22 PM.png
      1. 弹出窗口中选择 Install, 这会安装 python 插件
      Screen Shot 2021-09-07 at 8.58.27 PM.png
  1. 安装 python 插件中

    Screen Shot 2021-09-07 at 8.58.38 PM.png
  1. 插件安装完成后,会有如下提示,如果没有安装过 python, 选择第一个点击 button 继续
Screen Shot 2021-09-07 at 8.59.25 PM.png
  1. 如果自己已经安装过 python, 选择第二个来配置 python 解析器

    Screen Shot 2021-09-07 at 8.59.36 PM.png
  1. 然后选择你安装的 python 路径,如果有多个请选择 python3 最新版本

    Screen Shot 2021-09-07 at 8.59.42 PM.png
  1. 测试是否安装成功,在文件中输入

    print("hello world!")
    
    Screen Shot 2021-09-07 at 9.00.24 PM.png
  1. 文件中鼠标右键,然后选择 Run Selection/Line in Python Terminal

    Screen Shot 2021-09-07 at 9.00.35 PM.png
  1. 出现以下类似界面,即为安装成功
Screen Shot 2021-09-07 at 9.13.03 PM.png
  • PyCharm 社区版

    点击下载连接下载安装,注意选择社区版本

    1. 安装成功后,打开 PyCharm, 选择 New Project

      Screen Shot 2021-09-07 at 9.15.42 PM.png
  1. 选择第一个 Pure Python, 然后配置你的 python 解析器, 红框位置二选一即可
    Screen Shot 2021-09-07 at 9.16.02 PM.png

相关文章

网友评论

      本文标题:Python 环境安装

      本文链接:https://www.haomeiwen.com/subject/fsamwltx.html