Настройка .bash_profile после установки python - PullRequest
0 голосов
/ 05 апреля 2020

Я настраиваю python среду на Ма c (Каталина). Я установил 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.

Я хотел настроить псевдоним для "python", чтобы открыть python3, но .bash_profile там не было. Я создал его и добавил псевдоним, но мой псевдоним не работает

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

Кроме того, поскольку python был установлен до того, как был создан .bash_profile, мне не хватает содержания python Speci c в .bash_profile? Нужно ли переустанавливать python?

1 Ответ

0 голосов
/ 05 апреля 2020

Установите свой псевдоним, как показано ниже, в одинарных кавычках:

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.
>>>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...