From install to Run for Python3.7 and PyCharm on Mac

hello this Gerry Jenkins this is a video
to show you how to install, run, and write a program in Python 3.7 or later
in PyCharm on in Macintosh. Python is one of the most popular languages today. so
you can do all kinds of programming in Python. it’s one of the fastest growing
languages. the website to get Python and information on it this PyCharm is one of the most popular IDE s companies is made by JetBrains they also
make the Android development system Android studio that’s used by Google on
Android development so they do a free version of PyCharm which is a IDE for
developing just Python and it’s really good so we’re going to show you how to
install that note the Mac already has Python 2.7 installed which is considered
a legacy version of Python, you should be learning the newest Python if you’re
learning Python which is what we’re going to be installing as part of this
video. So a WARNING: do not remove the Python that comes on your Mac. it has three terminal commands:
python idle and python2.7 that you can run from terminal. it’s located in the Applications folder. There’s a programs in
/usr/bin, where you’ll find the these files and it’s also in the library
frameworks area so do not remove any of the original Python or mess with it you
can mess up other things in your Mac. So we’re going to be installing Python alongside the Python that’s already there. so let’s go
ahead and install it now, now the installation is very straightforward you
just go to, you go to downloads and click here, and go ahead
and save the file and then when you open it up that’s
called a package file and you’re just going to accept all the defaults. just
note it will install a 64-bit version which is what you need for almost every
modern computer and we’ll just go ahead and go through this you have to agree to
the license and then go ahead and hit install and put in your admin password it does install a folder in your
applications area so you can see this is in applications and and the idle app is
there which we’re going to use from the command line but it’s also available as
an application so I’m going to close that it’s all done I’m going to hit
close I’m going to remove the Installer and put it in the trash
I’m gonna do spotlight and go to terminal and what gotten installed was Python 3
which is a short name for Python 3.7 if you installed Python 3.8 when it comes
out it would also be called Python 3 and so you can see that’s our new version we
just installed I can print commands from it I can do some math so you can see
pythons working and it runs a little interpreter when you just run Python
this way you exit by calling a function called
exit there’s also a command called idle3 and that’ll pop up the new version in
an interpreter which is the idle environment which is a shell that you
can program from just for your information and there’s also a pip3
pip is a package manager for python to allow you to add new libraries or what
are called packages or modules to python and only need to type:
pip3 install something
and you might install pygame if you’re going to develop video games
with Python so that’s what pip3. Now there’s still the old Python the old
Python is just Python without a number this will show you that it’s still there
and there’s an old idle so if you open that up you’ll see it opens up the old
2.7 legacy idle so that’s where things are so now let’s go ahead and install
PyCharm. so to install PyCharm you go to I sometimes pronounce it P-Y charm, because I kind of learned it
that way but I understand it’s technically called P-I-E Charm (ˈpī),
so here you’re at the PyCharm page and you want to say download now there’s two versions
one you pay for and one is free the one you pay for if you’re a student there’s
a there’s a application you can make as a student to get it for free or as a
teacher so we’re gonna download the Community Edition which works for
everything you need for learning Python so it’s going to download a dmg image so
it takes a little time to do that so I’m going to go ahead and hit OK and I’ll
collapse the time in the video then now it’s uh finished downloading it it’s
mounting the image and all you have to do is drag those two applications to
install it and it’s going to show up here there it
is working right here it’s installed it so I’m going to go ahead and open up for
the first time and when you first open it you’ll see
this window and that that was an old project I had I didn’t clear out so
it’ll say I’ll create a new project or open and that’s what you primarily want
to do is open a previous project or a new project the project is just another
name for a folder that you keep all the files for one project in now before you
get started you want to do configure and follow some in supporting steps to tell
it where python is so do preferences you’re going to go to the project
interpreter and you want to make sure it will probably be blank here it’s only
this way because I’ve installed it before so what you want to do is make
sure you go to add and you’ll see this now here’s what’s
really important right now it defaults to what’s called virtual environment
which is very nice to use when you can become a little bit more advanced at
Python but we want to just always use the built in interpreter directly so
we’re going to click on system interpreter on the menu on the left of
the add Python interpreter and then it’s going to give you a list of the
interpreters that’s found on the system here and you can see there’s quite a few
of them when you see 2.7 or just the name Python those are the old legacy
interpreter we just installed 3.7 choose actually is it’s it’s loaded as Python 3
so I’m going to choose that and go ahead and hit OK so when you’re done you
should see it’s a Python 3.7 up here and it’ll have the the it’ll be in the
directory /usr/local/bin and then python 3 and go ahead and hit OK and now
it’s setup that whenever you create a project that will default to that
interpreter there and it allows you to actually change interpreters depending
on your project which is a more advanced feature it’s now we’re going to create a
new project and this is where it creates it so it’s going to create a special
folder called a PyCharmProjects inside your home folder which is my home folder
is under my name and then it has highlighted untitled that would be the
name if I didn’t do anything what I want to do a ‘Hello’ program so I’m going to
call it ‘hello’ and we’re all set so when you first
start it you’re gonna see this tip of the day and this is things you can find
out about how you use PyCharm you can just close this you can turn it off. if
you need it again it’s in the help menu called tip of the day so I’m going to
close that this is where you’re the folder that holds your files under
project hello. right here so we’re gonna use that
folder and put our files in there. external libraries points to things off
in Python so that kind of points to which Python you’re using so you don’t
usually do much with that I’m gonna right click here and choose
‘new python file’ you can also create other files like text files and HTML files but
python file we’re just going to click that and type ‘hello’,
so you don’t have to type .py which
is the standard extension for python files and now we’re ready to code, so I
can say print(“hello every one”) and you’ll see little squigglies like this this is
warning you about usually style variations called pep8 it says
there’s no new line at the file so you can fix that and make it go away and
they are a little annoying there is a place in the settings for a PyCharm
to turn off specific ones that are too annoying although it is useful to follow
those style changes so you can write code that’s follows the same style that
everyone else is doing so we run it you just right-click anywhere in the edit
area for if you want to run this file and you choose ‘run hello’ and it’s going
to run it right here and here it outputs ‘hello everyone’ and it’s done the line
just above this is what it input to terminal so I’m gonna actually copy this
line here so I’ll do a control C or command C on a
Mac so this is the Python command version3.7 and this is the file that I
just created so it has the full path so I’m gonna I’m gonna go back to terminal
and here’s the terminal and I’m going to paste in that line that I just copied
and hit enter and you’ll see it runs it in the terminal although I don’t need
the full path I just need to go to where my directory is. My directory is
so I’m at the root directory which is just the ‘gjenkins’ so this is where I am so I’m just gonna ‘cd Pyc’ hit tab to finish that and then ‘/hello’, just the name of project
enough I’ll do a listing of the directory there it is so I just say
python3 then enter key,
and that runs the right version python3 –version tells
you what version it is if i just say python — version that’s the legacy
system that’s part of the Mac so all that it actually installs you can see in
a special directory called
/usr/local/bin and to get a listing of everything that was installed as part of 3.7 I’m going
to do a special command here I’m gonna do ‘ls – l’ for long listing everything
in this (.) directory, the directory and I’m going to send it to another program pipe (|) it to grep which looks for patterns and I want all the patterns that have “3.7” so
that’s actually a regular expression for only showing, oops 3.73 backslash ‘dot’
seven quote and that’ll just list three point
seven and when I do that this is everything that was installed having to
a 3.7 in name, so I mentioned some commands I mentioned idle3 and pip3
and python3 and these other commands were for doing other things so that’s
something that’s more advanced so happy coding
I hope you enjoy this video sign in to my channel and there’s also an article
that also goes through this information that’s in the description of the video please subscribe to my channel , you’ll see an icon in the lower right to do that
and you’ll receive notifications when I post new videos , thank you