
For the purposes of this chapter we are going to make use of  demo-app , the project that we worked on together in the âCreate Your First Virtual Environmentâ chapter.
When you run PyCharm you should be prompted with the following welcome screen:

Click âOpenâ, and then select your  demo-app folder from Finder:

There you go - you have created your first PyCharm project. đ If you expand  demo-app in the project tree on the left hand side you should be able to see all of the files inside your project. At this point it should just be  demo.py and the  env directory - your virtual environment:

If you double-click on  demo.py in the project tree, the file will appear in the editor. You can then make any changes you wish:

Note that PyCharm (and indeed some other IDEs) work a little differently to traditional text/code editors in that they save your work automatically - you never have to click âFile -> Saveâ, or Ctrl/Command + S to save. Try it: add  print(r.text) to your editor and close PyCharm:

You will notice that as you type, PyCharm gives you lots of autocomplete options - a nice feature!
When you relaunch PyCharm you will be presented with a slightly different set of options. It will have options to âCreate New Projectâ, âOpen,â and âGet from Version Controlâ as before, but you will also have the option to open the  demo-app project you were working on moments ago:

Open the  demo-app and you will see that the  print(r.text) line of code has been retained:

Hey, presto! The autosave has worked! đ
One powerful feature of PyCharm is that you can link your PyCharm project to your virtual environment so that PyCharm knows which packages you have installed inside your virtual environment. This means that it can give you better autocomplete recommendations and correctly identify syntax errors when you are trying to import modules or use class methods that donât exist!
If your virtual environment is called  env then PyCharm should detect it and use it automatically in your PyCharm project. However, we can double-check this by selecting PyCharm -> Preferences from the menu-bar:Â

Once inside Preferences, go to âProject: demo - appâ followed by âProject Interpreterâ. Double-check that the Project Interpreter is set to the Python version inside your virtual environment. For example, in my case it is set to  ~/projects/demo-app/env/bin/python . PyCharm will also list the packages that you have installed inside your virtual environment, along with their dependencies:

This is essentially the same output as you get from running the  pip list command inside your terminal when your virtual environment is activated:
~/projects/demo-app
â source env/bin/activate
(env) ~/projects/demo-app
â pip list
Package  Version
---------- ----------
certifi  2020.4.5.1
chardet  3.0.4
idna    2.9
pip    10.0.1
requests  2.23.0
setuptools 39.0.1
urllib3Â Â 1.25.9Once you have successfully linked your PyCharm project to your virtual environment, you can also use the terminal inside PyCharm to run your script. To see this in action, click on the âTerminalâ button in the bottom left-hand corner of PyCharm:

This opens a terminal window inside PyCharm, with the virtual environment already activated:

You can now use the terminal window inside PyCharm to run the  demo.py file by running the command  python demo.py :

You should see the  200 status code being printed, as before, but also  r.text displays the HTML from the webpage itself.
For each of the  demo-app-2 and  demo-app-3  applications that you worked on/created in  Create a Python virtual environment with venv , set them up as projects on PyCharm. Make sure you:
Link the virtual environment associated with each application to the appropriate PyCharm project.
Can successfully run the application from the command line using the PyCharm terminal.
When working on a particular project, it is important to link PyCharm to your virtual environment so that PyCharm knows which Python packages you have installed.
With PyCharm, you can run your application/program in the built-in terminal - you donât need to use another terminal application if you donât want to!
Now that you have created your first project on PyCharm, letâs investigate how we can make use of even more of its functionality.