我正在Mac (Catalina)上设置python环境。我已经安装了python3,并想通过输入"python“从终端启动它。
epipko@Eugenes-Mac ~ % python
Python 2.7.16 (default, Dec 13 2019, 18:00:32)
[GCC 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.32.4) (-macos10.15-objc-s on darwin
Type "help", "copyright", "credits" or "license" for more information.
epipko@Eugenes-Mac ~ % python3
Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.我想为“.bash_profile”设置一个别名来打开python3,但是python不在那里。我已经创建了它并添加了别名,但我的别名不起作用
epipko@Eugenes-Mac ~ % ls -altr .bash_profile
ls: .bash_profile: No such file or directory
epipko@Eugenes-Mac ~ % touch .bash_profile
epipko@Eugenes-Mac ~ % chmod 700 .bash_profile
epipko@Eugenes-Mac ~ % ls -altr .bash_profile
-rwx------ 1 epipko staff 21 Apr 5 09:44 .bash_profile
epipko@Eugenes-Mac ~ % cat .bash_profile
alias python=python3另外,由于.bash_profile是在创建.bash_profile之前安装的,所以在python中是否缺少python特定的内容?我需要重新安装python吗?
发布于 2020-04-06 01:10:42
在单引号内设置别名,如下所示:
epipko@Eugenes-Mac ~ % cat .bash_profile
alias python='python3'编辑-1:在文件中添加上述内容后,运行source ~/.bash_profile或source ~/.bash_aliases或source ~/.bashrc。
例如:
$ python --version
Python 2.7.6
$ python3 --version
Python 3.8.2
$ alias python='python3'
$ python --version
Python 3.8.2
$ python
Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>https://stackoverflow.com/questions/61046131
复制相似问题