-1

I was trying to update my mac from python 2 to python 3 using this tutorial and tried the section called "what we should do"

https://opensource.com/article/19/5/python-3-default-mac

and everything is going well and I got to the part where you have to remove the "aliases we used in the sections above" and first I forgot to change his username to mine so It was not broken and I could still call python on the terminal and it would give me python 2.7.2 rather than the 3.7 I had installed and set to default.

aaaaaaaaas-MacBook-Pro:~ $  which python
/usr/bin/python

aaaaaaaaas-MacBook-Pro:~ aaaaaaaaa$ /Users/mbbroberg/.pyenv/shims/python
-bash: /Users/mbbroberg/.pyenv/shims/python: No such file or directory

aaaaaaaaas-MacBook-Pro:~ aaaaaaaaa$ python -V
Python 2.7.16

Then I noticed I used his username rather than mine so I decided to change it to mine.

aaaaaaaaas-MacBook-Pro:~ aaaaaaaaa$ which python
/Users/adrianabeltran/.pyenv/shims/python

aaaaaaaaas-MacBook-Pro:~ aaaaaaaaa$ /Users/aaaaaaaaa/.pyenv/shims/python 
Python 3.7.3 (default, Jun  8 2020, 13:42:02) 
[Clang 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> python -V
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'python' is not defined

and now I cannot use python on my computer anymore. when I call for the version or try to run python from the terminal it cannot find it and my pycharm ide does not run python either. I have tried to redownload python 3 and I still can't do it and I've looked to find the path I did and I cannot find it on my finder. I don't care if we could only turn it back to python 2 but please help me I really want to get to coding in python soon. Thank you!

  • It looks like it worked to me. The last line doesn't work because you're in the python interpretor, not BASH. Open a new terminal and try `/Users/aaaaaaaaa/.pyenv/shims/python -V`. You can also write the line `alias python3='/Users/aaaaaaaaa/.pyenv/shims/python'` in your `.bash_profile` if you want to be able to just type `python3` to launch python3 and `python` to launch python2 – CasualScience Jun 09 '20 at 03:41

1 Answers1

0

Yo I wouldn't use pyenv that way...it's not quite how it was intended, to call the executable in the shims folder directly. What I do is put eval "$(pyenv init -)" into my .bash_profile (or .bashrc or .zshrc depending on your shell of choice), and then using pyenv's commands, such as pyenv global 3.8.0 or pyenv local 3.7.0, that init command should automagically handle which python gets called when you invoke python on the command line.

Pete K
  • 118
  • 6