banner ad

Build Python development environment for Ubuntu 12.10

| April 19, 2013 | 0 Comments
1 Flares 1 Flares ×

Recent I build Python development environment ubuntu. There are many problems, so write down this post.
The system and software use:UBUNTU

Ubuntu 12.10
Python 2.7.3
Django 1.4.2
Pycharm 2.6.3
Postgresql 9.1

First, be sure backup your system. Because if your misuse will bring unnecessary trouble. I was mistakenly installed Postgresql, and then a big problem, and finally had to reinstall the system.

Ubuntu system comes with python 2.7, so no special settings. Of course, because of the use of the Django 1.4, you can not use Python 3.0 or later. So we do not re-install Python.

  • 1: install the JDK.

Because pycharm is written with Java, it is necessary to install JDK to run. If you have previously installed JDK, you can skip this step. The following method is to install and upgrade the JDK.

First of all, in order to insurance, you need to delete the lower version installed. The command line is as follows:
sudo apt-get purge openjdk *
sudo rm /var/lib/dpkg/info/oracle-java7-installer*sudo apt-get purge oracle-java7-installer*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update

Finally begin to install Oracle Java 7

sudo add-apt-repository ppa: webupd8team/javasudo apt-get update
sudo apt-get install oracle-java7-installer.

JDK install Finish.

  • 2 install Virtualenv and Virtualenvwrapper

Install the virtualenv mainly establish an independent python development environment. For A machine to create multiple different needs of the environment. It can create a different version of the program environment. Example, you can build a Django 1.4 environment, also can build Django 1.3 environment.

The installation of virtualenv is very simple.

pip install virtualenv

After installation, create a virtual environment, then install virtualenvwrapper

virtualenv ENV
source ENV / bin / activate

The beginning of the command line will be displayed into the virtual environment (ENV), then enter the environment, you can install virtualenvwrapper and Django.

Enter the command line
PIP install virtualenvwrapper is

  • 3. install Django:

1. Download the latest release from our download page.
2. Untar the downloaded file (eg tar xzvf Django-XYtar.gz, where XY is the version number of the latest release). If you’re using Windows, you can download the command-line tool bsdtar to do this, or you can use a GUI-based tool such as 7-zip.
3. Change into the directory created in step 2 (eg cd Django-XY).
4. If you’re using Linux, Mac OS X or some other flavor of Unix, enter the command sudo python install at the shell prompt. If you’re using Windows, start a command shell with administrator privileges and run the commandpython install. This will install Django in your Python installation’s site-packages directory.

  • 4. install PostgreSQL

Ubuntu 12.10 comes with Postgresql 9.1, you do not need to download, enter the command line can be installed in the terminal.

sudo apt-get install postgresql-9.1

  • 5.installation psycopg2

Need to re-enter the virtualenv environment.

source ENV / bin / activate

Then in a virtual environment, enter:
pip install psycopg2

Installation can be completed.

  • 6. install pycharm

1. Open the project settings, and click Python Interpreters page.
2. Click in the toolbar.
Create New Virtual Environment dialog box opens.
3. In the Create New Virtual Environment dialog box:
* In the Name field, type the name of the new virtual environment, or accept the suggested default name.
* In the Location field, specify the target directory, where the new virtual environment will be created.
* From Base interpreter drop-down list, select one of the configured Python interpreters, which will be used as the base for the new virtual environment.
* If you want the site-packages of the base interpreter to be visible from the virtual environment, select the check box Inherit global site-packages. If you leave this check box cleared, the new virtual environment will be completely isolated.
* 2.6+ If you want to assign the new virtual environment to be the project interpreter, make sure that the corresponding check box is selected.Also, you can make this virtual environment available to all projects, same as when an existing virtual environment is added.
If there is no special settings, pycharm default use the system’s Python environment, rather than using virtualenv we just created as a development environment. So it is necessary to further set to Pycharm virtual environment. The specific method is as follows, because the official gives a very detailed way, so I directly paste URL and content over.

Download PDF
1 Flares Twitter 0 Facebook 1 Google+ 0 Pin It Share 0 LinkedIn 0 Reddit 0 StumbleUpon 0 1 Flares ×

Tags: , , ,

Category: Python IDE

About the Author ()

My name is John Link.I am 26 years old. My major is Computer science and technology. I am a junior programmer with Python.

Leave a Reply

Your email address will not be published. Required fields are marked *

1 Flares Twitter 0 Facebook 1 Google+ 0 Pin It Share 0 LinkedIn 0 Reddit 0 StumbleUpon 0 1 Flares ×