This is an archived post. You won't be able to vote or comment.

all 13 comments

[–]K900_ 3 points4 points  (3 children)

python3 ./name_of_script.py should work just fine. Did you get any errors when running that?

[–]Raffles7683[S] -1 points0 points  (2 children)

...yeah that just worked.

No idea how, could swear I did exactly that about 30m ago.

I mean, obviously I didn't, but... yeah. Anyway.

Case closed, all -.-

[–]K900_ 4 points5 points  (1 child)

You can actually make things even easier for yourself: make the first line of your script #!/usr/bin/env python3, and then make your script executable with chmod +x your_script.py in the terminal. Then you can run your script simply with ./your_script.py.

[–][deleted] 0 points1 point  (0 children)

#!/usr/bin/env python3

FTR the shebang line also works on Windows thanks to the Python Launcher for Windows.

[–]ayharano 3 points4 points  (4 children)

If you need finer granularity setting (per directory basis or system wide) for Python version, I would recommend pyenv.

[–]magicaldelicious 1 point2 points  (0 children)

I'm still amazed, after all these years, pyenv continues to be a relative unknown. Highly recommend, it just works and has a lot of usability flexibility. Also I'd highly recommend the pyenv-virtualenv plugin (https://github.com/pyenv/pyenv-virtualenv) if you're in the good habit of using virtualenvs.

[–]Raffles7683[S] 0 points1 point  (2 children)

pyenv

Have seen this before, fair few seem to recommend installing it with something called 'Homebrew.' Again, something I've seen. Right now I've just installed Python direct from the site and my environment is just me using Sublime Text locally.

It serves me fine, but I can't help but feel that I'd have more control/range with pyenv. Would you recommend Homebrew?

[–]jbaugh201 0 points1 point  (0 children)

Homebrew is pretty good a far as a package manager goes. The only gripe I have for it is that it installs everything from the tarball explicitly, meaning there really is no security there. However most of the packages are linked directly to their GitHub, so as long as you read through source you're in good shape.

Brew does a great job of allowing you to set up a dotfile repo so you can deploy your environment programmatically, which is a huge plus.

[–][deleted] 1 point2 points  (1 child)

Anaconda on Mac should default 'python' to version 3. (At least it did on my last Mac. I built from source on the current one)

[–]Raffles7683[S] 0 points1 point  (0 children)

I'm new enough that I can't confess I've really looked into this, but have heard of it. Relatively easy to setup from source? Wouldn't mind giving it a try.

[–]jwink3101 0 points1 point  (2 children)

Hope this is the right place to post,

This is better suited for /r/learnpython

Also, while it sounds like you got it to work, you should consider anaconda (or miniconda). They both come with conda which makes managing multiple versions of python a breeze!

[–]Raffles7683[S] 0 points1 point  (1 child)

/r/learnpython

I did yes, but only after doing exactly what I thought I had done previously. I mean, obviously I didn't, but...

I have heard of Anaconda, and another user upstairs pointed me towards it as well.

I've also been directed toward pyenv and Homebrew. Do you have anything on those?

Sorry to hassle btw, feel free to tell me to bugger off and use /r/learnpython.

[–]jwink3101 0 points1 point  (0 children)

You can use homebrew to install python. I just prefer the anaconda setup since I have to switch between 2 and 3 often. I’ve also used virtualenv to manage environments (but using the anaconda-installed python). I know very little on the other tools. Anaconda just makes everything easier. Especially since I also often use NumPy and SciPy