{"id":228,"date":"2017-09-15T19:16:49","date_gmt":"2017-09-15T19:16:49","guid":{"rendered":"http:\/\/linux.suriyasuneel.com\/?p=228"},"modified":"2017-09-16T20:34:26","modified_gmt":"2017-09-16T20:34:26","slug":"python-startup","status":"publish","type":"post","link":"http:\/\/linux.suriyasuneel.com\/?p=228","title":{"rendered":"Python Startup"},"content":{"rendered":"<h2>Setup a new python<\/h2>\n<p>I used the information from this link <a href=\"https:\/\/jeffknupp.com\/blog\/2014\/02\/04\/starting-a-python-project-the-right-way\/\">https:\/\/jeffknupp.com\/blog\/2014\/02\/04\/starting-a-python-project-the-right-way\/<\/a><\/p>\n<h2>Install Python<\/h2>\n<p>First find out where the Python is installed. In my computer i installed it here<\/p>\n<p>C:\\Users\\&lt;user name&gt;\\AppData\\Local\\Programs\\Python\\Python36-32\\Scripts<\/p>\n<p>Add this to the PATH variable so that it will be helpful in setting up the virtual environment.<\/p>\n<p>Open the command prompt and go to the folder where you want to start a python projects. For example i was working on mywebproj. It will be located in D:\\Projects<\/p>\n<p>So from the command prompt, i go to D:\\Projects and then create a folder called mywebproj.<br \/>\nNow I have to create a virtualenv in that folder, so that all the python libraries that i&#8217;m going to install for this project are local to that project<\/p>\n<p>If the path is already set, then from the command line issue the following command<br \/>\nvirtualenv mywebproj<\/p>\n<p>it will create all the structure for a project and related libraries will be copied into that folder. Now if you use pip to install new libraries then it will be installed in that folder local to that project.<br \/>\nFirst we need to activate the virtualenv, by calling the command<br \/>\nmywebproj\\Scripts\\activate<br \/>\nThis is how it is in my windows machine.<br \/>\nNow the command line will look like this<br \/>\n(mywebproj)D:\\Projects\\mywebproj<\/p>\n<p>If you already installed Pycharm then open it and then open the project D:\\Projects\\mywebproj.<br \/>\nAfter that we need to select the interpreter properly(if it doesn&#8217;t automatically find out)<br \/>\nFile-&gt;Settings-&gt;Project mywebproj-&gt;Project Intepreter. Now select the Gear Icon and Select Add Local.<br \/>\nThen browse to the project folder and find python.exe D:\\Projects\\mywebproj\\Scripts\\python.exe<br \/>\nOnce you select the exe, then the Pycharm displays all the libraries installed for that virtual environment.<\/p>\n<h2>Mac OS Setup<\/h2>\n<p>The assumption is python 3.6 is already setup with pip3 and everything.<br \/>\nFirst create the project folder where it will be setup and in this case is mywebproj.<br \/>\nit will be set in \/Users\/&lt;user_name&gt;\/Documents\/Projects\/mywebproj<\/p>\n<p>Now issue the following command from the location \/Users\/&lt;user_name&gt;\/Documents\/Projects<\/p>\n<p>pyvenv mywebproj<\/p>\n<p>This will create the virtualenv in the folder mywebproj. Now activate the virtual environment by issuing the following command<\/p>\n<p>source mywebproj\/bin\/activate<\/p>\n<p>now you are in the virtual environment. You can check the version of the python and pip by issuing the following command<\/p>\n<p>python &#8211;version<\/p>\n<p>Python 3.6.2<\/p>\n<p>That tells you that the virtual environment is set to use Python 3.6.2. To make sure that the pycharm is using the correct interpreter, once you open the pycharm and selected the correct project, now<\/p>\n<p>Pycharm Community Edition -&gt; Preferences -&gt; Project Interpreter(mywebproj). Here you can select the correct interpreter if it is not already setup<\/p>\n<p>Now install the required libraries by issuing the command pip. to install the library requests<\/p>\n<p>pip install requests<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setup a new python I used the information from this link https:\/\/jeffknupp.com\/blog\/2014\/02\/04\/starting-a-python-project-the-right-way\/ Install Python First find out where the Python is installed. In my computer i installed it here C:\\Users\\&lt;user name&gt;\\AppData\\Local\\Programs\\Python\\Python36-32\\Scripts Add this to the PATH variable so that it will be helpful in setting up the virtual environment. Open the command prompt and go [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"_links":{"self":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/228"}],"collection":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=228"}],"version-history":[{"count":6,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/228\/revisions"}],"predecessor-version":[{"id":234,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=\/wp\/v2\/posts\/228\/revisions\/234"}],"wp:attachment":[{"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=228"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=228"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/linux.suriyasuneel.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=228"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}