Labels

Monday, May 25, 2015

Set up the Python environment for your research project

To set up the environment for my research project, I need several tools as:

C# (comes with Visual Studio)


MS SQL server management studio


MatLab


Python


R.


=====================================================


C# comes with Visual Studio. Now one can get a free version of VS from Microsoft. This free version is called "community versity" of VS. It is compact, simplified but should meet most of your research needs, unless you are running a huge project and cooperating with a bunch of people. If this is the case, you probably should have VS purchased by your department/institute.


MS SQL server also has a free version called "Express".


For, MatLab, you need with pay for it or request your department/institute purchase and install it for you.


=====================================================


Let's talk about Python.


Python evolvs to 3.4. But tons of applications are still on 2.7. For me, 3.4 is better because I always want to pursuit the latest version. However if you know that your prj requires high compatibility, go to 2.7.


First step, download and install Python 3.4 or 2.7.


Second step, go and get an IDE for your convenient. 

Some guys claim they use notepad (from MS) or the opensource notepad++ for Python writing. I guess they are really expert in Python. If you are reading this post, I bet you are as fresh as me. So please find yourself a comfortable IDE. I personally use PyCharm from JetBrains (google it). Many other IDEs are also recommended by others like: Canopy, Spyder, etc. Go and have  try.

Third step, find and install the packages you need.

I guess the core packages I need would include Numpy and Scipy for scientific calculation, Matplotlib for professional plotting, pymssql for MSSQL database connection, and pip for package management. The following table shows how and where you can get them:


Package name
How to get it
Note and resources
Numpy and Scipy

download exe for win and install
download link: http://www.scipy.org/scipylib/download.html
Matplotlib

download exe for win and install
download link: http://matplotlib.org/downloads.html
pip

upgrade through PyCharm package manager
To access the package manager: File->Settings->Project: Python->Project Interpreter->choose yours, for example 3.4.2. Then you will find some packages installed with your Python. To add one, click the plus on right. To upgrade one, click it and then click the up arrow on right
pymssql

installed through PyCharm package manager

I have other posts regarding the installation of pymssql and numpy. If interested, you can check them out.

Up to now, you should have enough resources for your work. Have Fun!

=====================================================

Trouble shooting

The main problem I got during the process is the pip thing.

As some online resources suggested, I tried to install pymssql through pip command (it means: Start->cmd->type "pip install ****"). Every time I did so, I got error reading ""pip" is not recognized as an internal or external command".

The reason for this error is the wrong value of the item "PATH" in your system's "Environment variables". The  command "pip" locatees in your Python installation folder and is not added to this PATH. Go and take a look at it by a) type "echo %PATH%" in your cmd window, or b) right click "Computer"->Properties->Advanced system settings->Environment Variables. You may get a long PATH varible.

The solution to this is to change the PATH variable by adding "C:\Python34\Scripts\" at the end of PATH value. Make sure you add a semi coma before it.

Another thing I noticed was that, some Canopy path was in the path. I installed "Enthought Canopy" before PyCharm. And then found I prefer PyCharm over the Canopy, so I uninstalled it. But the path remained in the Env variable. I had to deleve them mannually.

If you readers encounts any other trouble when setting up your lovely (you are going to work with it for a long time, it deserves to be lovely), please leave your comments and let's discuss!  

====================================================

1 comment: