{"id":52,"date":"2020-05-01T23:21:17","date_gmt":"2020-05-02T03:21:17","guid":{"rendered":"https:\/\/blog.lemonthy.com\/?p=52"},"modified":"2020-08-09T16:22:06","modified_gmt":"2020-08-09T20:22:06","slug":"python-environment-guide-pycharm-ide","status":"publish","type":"post","link":"https:\/\/blog.lemonthy.com\/?p=52","title":{"rendered":"Python environment guide [python , Pycharm IDE]"},"content":{"rendered":"\n<p>In beginning of our Python Programming Basic class, we use web version python code you run on trinket.  You may ask &#8220;How can I run Python code on my computer out of the trinket environment?&#8221;. Yes, this is a good question. We learn Python to be used in a real environment on our local computer. Next, let me introduce you to the common methods of building a Python environment.  In our later part Python Programming Basic class and Python Crawler Advance class, we use Pycharm as our local python IDE. <\/p>\n\n\n\n<p>PyCharm is a cross-platform editor developed by JetBrains. Pycharm provides all the tools you need for productive Python development. Among many editors, Pycharm is relatively friendly to new users. On the one hand, it will automatically complete the code. For example, if you write the front quotes, it will automatically fill in the back quotes; on the other hand ( More importantly) It will prompt you when the code is written. Therefore, the first article we recommend in the editor recommends Pycharm.<\/p>\n\n\n\n<p>This article is divided into three parts, namely <strong>Installing Python<\/strong>, <strong>Third-party library installation<\/strong> and <strong><strong>Installing Pycharm<\/strong> and use<\/strong><\/p>\n\n\n\n<p>Below are the detailed steps for installing Python and PyCharm<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>Installing Python<\/strong><\/h1>\n\n\n\n<p><strong>Step 1)<\/strong>&nbsp;To download and install Python visit the official website of Python&nbsp;<a href=\"https:\/\/www.python.org\/downloads\/\">https:\/\/www.python.org\/downloads\/<\/a>&nbsp;and choose your version. We have chosen currently latest Python version. Click the Download button to enter the download page, there are a variety of versions at the bottom to choose from.<br>We choose the appropriate version according to our system type (32-bit or 64-bit) and click to download, generally we choose executable installer. The differences between the various versions are:<br>embeddable zip file: embedded version, can be integrated into other applications<br>web-based installer: network installation<br>executable installer: executable file (* .exe) installation<br>We selected Windows x86-64 e installer here, double-click to open after the download is complete, you can see the interface as shown below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/python1.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 2)<\/strong>&nbsp;Once the download is complete, run the exe for install Python. <\/p>\n\n\n\n<p>Note: first check all the boxes. The Add Python 3.8 to PATH circled in the figure must be checked, otherwise \u2018python\u2019 will give error after installation. then click Install Now<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/python2.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 3)<\/strong>&nbsp;You can see Python installing at this point.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/python3.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 4)<\/strong>&nbsp;When it finishes, you can see a screen that says the Setup was successful. Now click on &#8220;Close&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/python4.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 5)<\/strong>&nbsp;After closing the installation interface, we use the win + r shortcut key to open the run window, enter cmd in the run window, and click the OK button to open the command prompt, which is the command line.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/python5.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 6)<\/strong> Enter python in the command prompt window and press Enter. When you see the version information of Python, you have entered the Python interactive environment. Then we can enter the python code after &gt;&gt;&gt; to execute.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/python6.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Install on Mac<\/strong><br>Mac generally comes with Python, but the version is older. Next, let \u2019s talk about how to install the latest one. Choose one of the following two methods:<br><br>Go to the official website to download and install like Windows;<br>Install through Homebrew. If Homebrew is already installed, simply execute in the terminal: <\/p>\n\n\n\n<p>brew install python3<\/p>\n\n\n\n<p>Manually run python program in command line is hard. The more recommended way is to use an editor or IDE to create a py file to write and run code. A good coding tool can greatly improve coding efficiency. Here, we recommend using vscode or pycharm.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>Third-party library installation<\/strong><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><br>The reason why Python is so powerful is inseparable from its rich third-party libraries. Next we look at how to install third-party libraries.<br><br>Python uses pip to manage third-party libraries. Python 2.7.9 or Python 3.4 and above all come with pip tools, which we can use directly.<br><br>First, we open the command prompt window by the method mentioned above, then enter the name of the third-party library pip install and press Enter to start the installation. For example, we want to install the requests library, just type <\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">pip install requests<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">and then press Enter key to install<br><br>It should be noted that the command is entered directly in the command prompt window(or in Terminal window in pycharm). Many students open the command prompt, enter python, and then install the command. This is wrong.<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/python7.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>Installing Pycharm and Use<\/strong><\/h1>\n\n\n\n<p><strong>Step 1)<\/strong>&nbsp;To download PyCharm visit the website&nbsp;<a href=\"https:\/\/www.jetbrains.com\/pycharm\/download\/\">https:\/\/www.jetbrains.com\/pycharm\/download\/<\/a>&nbsp;and Click the &#8220;DOWNLOAD&#8221; link under the Community Section, which is free.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm1.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 2)<\/strong>&nbsp;Once the download is complete, run the exe for install PyCharm. The setup wizard should have started. Click \u201cNext\u201d.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.guru99.com\/images\/Pythonnew\/Python2.6.png\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm2.jpg\" alt=\"How to Install Python on Windows with Pycharm IDE\" title=\"How to Install Pycharm\"\/><\/a><\/figure>\n\n\n\n<p><strong>Step 3)<\/strong>&nbsp;On the next screen, Change the installation path if required. Click \u201cNext\u201d.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.guru99.com\/images\/Pythonnew\/Python2.7.png\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm3.jpg\" alt=\"How to Install Python on Windows with Pycharm IDE\" title=\"How to Install Pycharm\"\/><\/a><\/figure>\n\n\n\n<p><strong>Step 4)<\/strong>&nbsp;On the next screen, Check all boxes first,  which create a desktop shortcut, associate .py and add PATH. Then click on \u201cNext\u201d.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.guru99.com\/images\/Pythonnew\/Python2.8.png\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm4.jpg\" alt=\"How to Install Python on Windows with Pycharm IDE\" title=\"How to Install Pycharm\"\/><\/a><\/figure>\n\n\n\n<p><strong>Step 5)<\/strong>&nbsp;Choose the start menu folder. Keep selected JetBrains and click on \u201cInstall\u201d.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm5.jpg\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm5.jpg\" alt=\"How to Install Python on Windows with Pycharm IDE\" title=\"How to Install Pycharm\"\/><\/a><\/figure>\n\n\n\n<p><strong>Step 6)<\/strong>&nbsp;Wait for the installation to finish.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.guru99.com\/images\/Pythonnew\/Python2.10.png\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm6.jpg\" alt=\"How to Install Python on Windows with Pycharm IDE\" title=\"How to Install Pycharm\"\/><\/a><\/figure>\n\n\n\n<p><strong>Step 7)<\/strong>&nbsp;Once installation finished, you should receive a message screen that PyCharm is installed. (After the installation, the computer will be required to restart, select the one above to automatically restart, select the next one to manually restart. choose either one is ok).  click \u201cFinish\u201d.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.guru99.com\/images\/Pythonnew\/Python2.11.png\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm7.jpg\" alt=\"How to Install Python on Windows with Pycharm IDE\" title=\"How to Install Pycharm\"\/><\/a><\/figure>\n\n\n\n<p><strong>Step 8)&nbsp;<\/strong> Find your new installed PyCharm program on desktop . double click to Open it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm8.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 9)&nbsp;<\/strong> After you open Pycharm,  you will be asked if you want to enter the previous settings. For the first installation, select \u201cDo not import\u201d<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.guru99.com\/images\/Pythonnew\/Python2.last.png\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm9.jpg\" alt=\"How to Install Python on Windows with Pycharm IDE\" title=\"How to Install Pycharm\"\/><\/a><figcaption><br><\/figcaption><\/figure>\n\n\n\n<p><strong>Step 10) <\/strong>Privacy policy, please check if you have no patience, then continue<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm10.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 11) <\/strong>Click Create New Project, or Open your folder. We suggest create a folder on desktop name python, then open the folder python on desktop. In our class, we need to create at least 3 folders under python: python1, python2, python3 for your diffrent levels of python class.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm11.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 12) <\/strong>If you haven&#8217;t create folders in pycharm before, it is easy, Just right click on python folder in left side, select New, then select Directory . <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm12.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 13) <\/strong>type in name of directory , for example, python1, press Enter . Create python1 folder<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm13.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 14) <\/strong>Right click on python1 folder in left side, select New, then select Directory . type in name of 1st class in Python Programming Basic class, 1print function and variables (You can go to 1st Basic class and copy the class name from lemonthy.ca), press Enter<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm14.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 15) <\/strong>Right click on 1print function and variables folder in left side, select New, then select file. type in name of 1st execs in Python Programming Basic class, 101No_quotes.py (You can go to 1st Basic class and copy the exec name from lemonthy.ca), press Enter<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm15.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p><strong>Step 16) <\/strong>double click on new file 101No_quotes.py.  type your code in 1st class. There are 3 ways to run the code: 1. right click on empty space of code on screen , then select Run  101No_quotes.py . 2. or you can click green triangle run button on top right side of toolbar. 3. you can press shortcut key Ctrl+Shift+F10 <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/lemonthy.ca\/pic\/py\/c09\/pycharm16.jpg\" alt=\"\"\/><\/figure>\n\n\n\n<p>The last is our intergrated Anaconda. Anaconda is a large collection that includes Python and its commonly used tools and modules. For beginners, just installing Anaconda is enough!  Please google how to install Anaconda . and follow the instruction to install<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In beginning of our Python Programming Basic class, we use web version python code you run on trinket. You may ask &#8220;How can I run Python code on my computer out of the trinket environment?&#8221;. Yes, this is a good question. We learn Python to be used in a real environment on our local computer. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/blog.lemonthy.com\/?p=52\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Python environment guide [python , Pycharm IDE]&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=52"}],"version-history":[{"count":3,"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=\/wp\/v2\/posts\/52\/revisions\/89"}],"wp:attachment":[{"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.lemonthy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}