If your virtual environment is called env then P圜harm should detect it and use it automatically in your P圜harm project.
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! One powerful feature of P圜harm is that you can link your P圜harm project to your virtual environment so that P圜harm knows which packages you have installed inside your virtual environment. Hey, presto! The autosave has worked! ? Link your P圜harm project to your Virtual Environment
#Pycharm python code#
Open the demo-app and you will see that the print(r.text) line of code has been retained: P圜harm autosave. 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: Opening a project with P圜harm. When you relaunch P圜harm you will be presented with a slightly different set of options. You will notice that as you type, P圜harm gives you lots of autocomplete options - a nice feature! Try it: add print(r.text) to your editor and close P圜harm: P圜harm autocompletion. Note that P圜harm (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. You can then make any changes you wish: Opening a file with P圜harm. If you double-click on demo.py in the project tree, the file will appear in the editor. At this point it should just be demo.py and the env directory - your virtual environment: P圜harm in the Applications folder. ? 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. There you go - you have created your first P圜harm project. When you run P圜harm you should be prompted with the following welcome screen:Ĭlick ‘Open’, and then select your demo-app folder from Finder: Opening a project with P圜harm.
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.