• mac下python3.7和python3.8环境变量配置


    mac电脑自带python2.7,并且默认使用python2.7。但是现在用 python开发东西大家基本上都是使用python3,这里说一下怎么把电脑的python设置为默认python3

    官网下载python安装包,直接运行安装。

    但你在Terminal中运行python3的话,也可以运行。但mac把python3.8安装到了一个非常难找的位置:/Library/Frameworks/Python.framework/Versions/3.8/bin。

    终端运行:which python3,就会看到python的路径

    user:~ user$ which python3
    /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 

    打开环境变量文件:

    user:~ user$ open  .bash_profile  #打开环境变量文件
    user:~ user$ touch .bash_profile  #生效更改后的环境变量

    把这一段放到环境变量文件中并保存(直接推出就自动保存了哦),

    # Setting PATH for Python 3.7

    # The original version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
    export PATH
    alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.7"

    生效环境变量:touch .bash_profile

    python3.8

    步骤和python3.7一样,但是放到环境变量中的地址为下面一段,

    # Setting PATH for Python 3.8
    # The original version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.8/bin:${PATH}"
    export PATH
    alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3"

    配置python3.8过程中我遇到的问题:

    开始我的环境变量配置方式和python3.7一样

    写的:alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8"(当然其他相应的也改为3.8)

    但是在终端运行时,提示我找不到这个文件,如下图:

    user:~ user$ python
    -bash: ”/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8”: No such file or directory #提示我找不到这个文件
    
    user:
    ~ user$ /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 #手动运行文件,发现这个文件是存在的,并且可以进入python3.8环境 Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> quit(),

    后来用which python3找到一个路径,放在环境变量中试了试,发现竟然成功了(我也很迷惑为什么,有知道的可以告诉我)

    user:~ user$ which python3
    /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 

    所以python3.8粘贴到环境变量里面的文件就变成了上面用的的。

    好了,希望能帮到遇到相同问题的人^ _ ^

  • 相关阅读:
    OneThink友情链接插件使用!
    OneThink生成分类树方法(list_to_tree)使用!
    OneThink视图模型进行组合查询!文档组合文档详情
    Atitit.数据操作dsl 的设计 ---linq 方案
    Atitit.数据操作dsl 的设计 ---linq 方案
    Atitit.Atiposter 发帖机 信息发布器 v7 q516
    Atitit.Atiposter 发帖机 信息发布器 v7 q516
    Atitit.http连接合并组件   ConnReducerV3 新特性
    Atitit.http连接合并组件   ConnReducerV3 新特性
    Atitit.减少http请求数方案
  • 原文地址:https://www.cnblogs.com/yuer011/p/12423710.html
Copyright © 2020-2023  润新知