Python being the new fashionable language, especially in Finance industry, I started learning it. I downloaded it from the Python website - Python version 3.5.2 - and it successfully installed... in my Application folder. Just so you know a little bit more about myself, I did an IT engineering school in France, so I have an IT culture, but I never had the soul of a hacker so some things might be more difficult than others.
Started to code on Python IDE, then I created an executable python file and when I tried to execute it ... error!!
This is what I got when I executed my file (bissextile.py - file is supposed to ask the user to enter a year and tell him if this year is bissextile):
Last login: Tue Aug 9 23:24:02 on ttys000
MacBook-Pro-de-Tebah:~ tebahsaboun$ cd '/Users/tebahsaboun/Desktop/' && '/usr/bin/pythonw' -d -v '/Users/tebahsaboun/Desktop/bissextile.py' && echo Exit status: $? && exit 1
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py
import site # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.pyc
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py
import os # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.pyc
import errno # builtin
import posix # builtin
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.py
import posixpath # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpath.pyc
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/stat.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/stat.py
import stat # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/stat.pyc
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py
import genericpath # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.pyc
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/warnings.pyc matches
[...] A LOT OF STUFF THAT'S THE SAME AS BEFORE
import encodings.aliases # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/aliases.pyc
# /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py
import encodings.utf_8 # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.pyc
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
File "/Users/tebahsaboun/Desktop/bissextile.py", line 1
{\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf470
^
SyntaxError: unexpected character after line continuation character
# A lot of cleaning up files after that...
So, I saw here two issues: 1) my file doesn't work ... 2) the shell is not using Python 3.5 but Python 2.7 which is the problem I need help for.
Lots of research on internet, I was about to follow that tutorial: https://wolfpaulus.com/journal/mac/installing_python_osx/comment-page-3/#comment-101285 ...and about to delete some system files from my mac :) which it didn't let me do...decided that I didn't really know what I was doing and that I should dig a little more in the internet. For the record, here is what I have in /System/Library/Frameworks/python.framework/Versions/ :
So I found something called "Homebrew" that is suppose to install Python for you and I followed this great tutorial: http://blog.manbolo.com/2014/09/27/use-python-effectively-on-os-x#p1 Asking Homebrew to install Python 3.5 instead of Python 2.7 (steps are absolutely the same) which I apparently did.
So I did the verification suggested in the tutorial to be sure that I was using the right version of Python but when I asked the shell I still got Python 2.7. I checked my /etc/paths file which is as follows:
/usr/local/bin
/usr/bin
/bin
/usr/bin
/bin
/usr/local/bin is the first binary in the file and I checked the folder it contains Python 3.5 indeed. But no matter what is the first line is in that file I get : MacBook-Pro-de-Tebah:~ tebahsaboun$ which python /usr/bin/python and :
**MacBook-Pro-de-Tebah:~ tebahsaboun$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.**
I can't put all the links that I have researched so far ( especially stack overflow articles by the way ;) ) cause I don't have enough "reputation", but I did a lot of research and no article seems to respond to my problem. And I don't understand what is wrong.