Saturday, November 8, 2014

Preparing Python Environment

Yes, I also using Python....
And since I use it in windows, preparing the environment it's a bit different with if its on Linux
The good thing is on python version is 3.x, the virtualenv is already part of the python basic installer.

To create new virtualenv in d:\python\venv\pylons:
C:\Users\Desson>python -m venv d:\python\venv\pylons
To activate virtualenv:
C:\Users\Desson>d:\python\venv\pylons\Scripts\activate.bat
And now, the virtuanenv is active:
(pylons) C:\Users\Desson>
Now you can work with this 'environment' and install 'anything you need' via easy_install (or pip)
Add virtualenv to Pycharm
I'm using Pycharm as my main IDE (Beside Notepad+, for small tasks), since we have new virtualenv, we need to bind this virtualenv. Jetbrains already documented the process in https://www.jetbrains.com/pycharm/help/adding-existing-virtual-environment.html, I only copied here (with my own words):
  1. Go to Project Settings, find Project Interpreter page, click the 'gear-wheel' button on the right.
  2. In the drop-down list, choose Add local 
  3. In the Select Python Interpreter dialog box that opens, choose the desired Python executable (in our virtualenv), and click OK.
The result should be like this:
And after that? Happy coding...


No comments:

Post a Comment