#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2015
    Posts
    18
    Rep Power
    0

    How to use 3.4 instead of 2.7


    Hi. I just downloaded python 3.4.3 but when I check in the command line what version
    of python I'm using it says I'm using 2.7 How do I use 3.4 instead? Also what complications
    might I expect in making the switch to 3.4. Will my current text files of code stop working correctly
    due to syntax errors etc... I know very little about the differences between 2.7 and 3.4. What
    should I know going into it?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    India
    Posts
    200
    Rep Power
    4
    Originally Posted by ThomasStutman
    Hi. I just downloaded python 3.4.3 but when I check in the command line what version
    of python I'm using it says I'm using 2.7 How do I use 3.4 instead? Also what complications
    might I expect in making the switch to 3.4. Will my current text files of code stop working correctly
    due to syntax errors etc... I know very little about the differences between 2.7 and 3.4. What
    should I know going into it?
    There are not much differences between 3.4 and 2.7 but some older programs may not work on the newer versions and they may require some minor tweaking. I'll advise you to stick the version you've been using then switch when it seems necessary. Some older libraries and packages still use 2.7, so if you're looking for compatibility its best to use an older version. A detailed comparison can be found here: https://wiki.python.org/moin/Python2orPython3

    I just downloaded python 3.4.3 but when I check in the command line what version of python I'm using it says I'm using 2.7 How do I use 3.4 instead?
    Are you sure that you're launching python 3.4 from its original executable, which is \Python34\python.exe on windows or /usr/bin/python on most linux distros. Or you might have added python2.7 to your path environment-variable (on windows), if it is so then launch the python3.4 executable from its original location instead calling it from the command-line. You can check which python installation is added to the PATH by typing:

    Code:
    >path
    on windows

    or
    Code:
    echo $PATH
    on linux.
    Last edited by hexman; May 20th, 2015 at 02:12 AM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Joensuu, Finland
    Posts
    471
    Rep Power
    69
    On most popular distros, you can say “python3” instead of “python”, or use “#!/usr/bin/env python3” instead of “#!/usr/bin/env python” in script files.
    My armada: Debian GNU/Linux 8 (desktop, home laptop, work laptop), Raspbian GNU/Linux 8 (nameserver), Ubuntu 14.04.3 LTS (HTPC), PC-BSD 10.2 (testbed), Android 4.2.1 (tablet)
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    India
    Posts
    200
    Rep Power
    4
    Originally Posted by SuperOscar
    On most popular distros, you can say “python3” instead of “python”, or use “#!/usr/bin/env python3” instead of “#!/usr/bin/env python” in script files.
    Yeah saw that on an SO question, haven't used python in a while. Back then, when python 3.2 was released, I was using 2.6 as the MIT/OCW course was using that. I don't like shebang lines for some reason, as they can cause some portability problems or more probably because I used a microsoft os instead of a *nix when I used to play around with python .
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Joensuu, Finland
    Posts
    471
    Rep Power
    69
    Originally Posted by hexman
    I don't like shebang lines for some reason,
    Well they are kind of necessary evil—don’t look too good but do the job. At least #! is cleaner than what OS/2 had, the “comspec” line.
    My armada: Debian GNU/Linux 8 (desktop, home laptop, work laptop), Raspbian GNU/Linux 8 (nameserver), Ubuntu 14.04.3 LTS (HTPC), PC-BSD 10.2 (testbed), Android 4.2.1 (tablet)
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Location
    India
    Posts
    200
    Rep Power
    4
    Originally Posted by SuperOscar
    Well they are kind of necessary evil—don’t look too good but do the job. At least #! is cleaner than what OS/2 had, the “comspec” line.
    Yeah I've read that *nix systems identify those binary files with something like a magic-number, bits embedded in the file; that's the reason why executable-files still work even after being stripped off their file-extension unlike most microsoft-systems which recognize a file-type with its file-extension, while in linux the extension is only for human-understanding. Looks like I swayed off-topic again, sorry for that . I believe that the OP's must've got their answer by now.
  12. #7
  13. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    635
    Rep Power
    68
    I hate to tell you this, the differences between Python2 and Python3 go well beyond the print function. Many Python3 functions have become generators and many other
    functions expect to receive byte strings and return byte strings rather than strings. Many of those differences will not be fixed with the 2to3.py utility.

    See ...
    Dive Into Python 3
    appendix A for Py2-to-Py3 differences

    Comments on this post

    • b49P23TIvg agrees
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo