"Go" Windows and Linux build the Python integrated development environment IDE

Source: Internet
Author: User
Tags linux shell commands postgres createdb virtual environment virtualenv


The system and software used
Python 2.7/python 3
Pycharm 2.6.3

Postgresql 9.1
{Before starting, you can make a backup of the system. If you mistakenly install PostgreSQL, there is a big problem, you have to put the system to reload}

Install Python

Install Python

1. Ubuntu 12.04 system comes with Python 2.7, directly with the line. (with Django 1.4, you can't use Python 3.0 or later, so you don't have to reinstall Python)
2. Ubuntu 14.04 system comes with Python 3.4, directly with the line.

3. Windows to python download installation python, recommended Python3

Investigate Python version: [email protected]:~$python--version

Upgrade Python version

To view the Python version:

$ python -VPython 2.6.6

Upgrade version to 2.7:

$Python2.7.6:$ wget http://python.org/ftp< Span class= "Hljs-regexp" >/python/2.7. 6/python-2.7. 6.tar.xz$ tar xf python-2.7.< Span class= "Hljs-number" >6.tar.xz$ cd Python-2.7. 6$./configure--prefix=/usr/ Local--ENABLE-UNICODE=UCS4--enable-shared ldflags= "-Wl,- Rpath/usr/local/lib "$ make && make Altinstall      

Establish a soft connection so that the system default Python points to python2.7

$ mv /usr/bin/python /usr/bin/python2.6.6 $ ln -s /usr/local/bin/python2.7 /usr/bin/python 

To view the Python version again:

$ python -VPython 2.7.6

/************************************************************************************************************** ***********************************************************************

Do not ignore the things in the * * can be temporarily ignored

5. Installing PostgreSQL
Because Ubuntu 12.10 comes with Postgresql 9.1, you don't have to download it, you can install it directly in the terminal by typing the command line.
The command line is as follows:
sudo apt-get install postgresql-9.1
Then install the necessary packages, and attach the website's introduction and website. Some packages may have been installed before, but for the sake of insurance, install one side according to the official introduction.
* Postgresql-client-9.1-client libraries and client binaries
* Postgresql-9.1-core Database server
* Postgresql-contrib-9.1-additional supplied modules
* Libpq-dev-libraries and headers for C language frontend development
* Postgresql-server-dev-9.1-libraries and headers for C language backend development
* Pgadmin3-pgadmin III Graphical administration utility

Just replace the postgresql-9.1 in the command line with the name of the next bread. For example, if you need to install postgresql-client-9.1, enter
sudo apt-get install postgresql-client-9.1
The following are all the same.
After you install PostgreSQL, you need to make some settings for the database, such as adding role, creating a database, and so on. Here's how:
set the user and password for PostgreSQL
sudo-u postgres CreateUser
Then follow the prompts to add the user
The first hint is to enter a user name and then ask if the user is a superuser, is not allowed to create a database, is not allowed to add new users. You can create a user by answering as needed.
Create a database
sudo-u postgres createdb mydb#mydb is the name of the database and can be set as you wish
After creation, use the Psql command to set the password of the user you just created, and give this user permission to access the database
Sudo-u postgres psqlpostgres=# alter user Linuxpoison with encrypted password ' password ';
postgres=# Grant all privileges on the database linuxdb to Linuxpoison;
You can then use \l to see the database that has been successfully created and the user who has just been added and has access to the database.

6. Installing PSYCOPG2

Need to re-enter the VIRTUALENV environment just now.
SOURCE Env/bin/activate
Then in the virtual environment, enter
Pip Install PSYCOPG2
The installation will be complete.
When you need to use the data, for example in Django settings.py, add the import psycopg2. Then add postgresql_psycopg2 at the end of the database engine.

*************************************************************************************************************** **********************************************************************/

I. Installation of the Python integrated development environment Pycharm

Installing the JDK
Because the Pycharm (Python IDE) is written in Java, the JDK must be installed to run. If you have previously installed a JDK, you can skip this step.

under Linux:
Before installation, perform java-version on the terminal

[Email protected]:~ $java--version
The program ' Java ' is already included in the following packages:
* Gcj-4.6-jre-headless
* Openjdk-6-jre-headless
* Gcj-4.5-jre-headless
* Openjdk-7-jre-headless
Please try: sudo apt-get install < selected packages >

Description The system does not have any JDK software

If it is already installed, you need to remove the earlier installed version. The command line is as follows:
sudo apt-get purge openjdk*
If the JDK you previously installed is from another PPA, you need to do the following steps to install the new JDK
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

Start installation of Oracle Java (note: Previously written a Java-installed blog, easier, more recommended, can be consulted).

Installing the JDK on Ubuntu 12.04 Lts is not complicated by itself, but the newer version of Ubuntu is not supported directly through the Apt-get installation.

1.Oracle official website Download the corresponding version of the JDK installation package , such as Jdk8-linux 64-bit version of: jdk-8u20-linux-x64.tar.gz. Download the file to/opt below.

[Email Protected]:/opt#wget http://download.oracle.com/otn-pub/java/jdk/8u20-b26/jdk-8u20-linux-x64.tar.gz

2. Modify the Environment variables:

sudo vim/etc/environment //can also be modified ~/.BASHRC or ~/.profile

The end of the first line "..." Plus

: ${java_home}/bin
At the end of the file, add

Export java_home=/opt/jdk1.7.0_07
Export Classpath=.:${java_home}/lib:${jre_home}/lib

Path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:${java_home}/ Bin
Export java_home=/opt/jdk1.8.0_25
Export Classpath=.:${java_home}/lib:${jre_home}/lib

3. Modify the system default JDK to the JDK we just installed because there may be other installed JDK in the system

sudo update-alternatives--install/usr/bin/java Java/opt/jdk1.8.0_25/bin/java 300;

sudo update-alternatives--install/usr/bin/javac Javac/opt/jdk1.8.0_25/bin/javac 300;

sudo update-alternatives--install/usr/bin/javah javah/opt/jdk1.8.0_25/bin/javah 300;

sudo update-alternatives--install/usr/bin/jar Jar/opt/jdk1.8.0_25/bin/jar 300

4. For the configuration to take effect, you must restart the machine or enter it at the command line

. /etc/environment

Configure the JVM priority: (You can skip this step if you do not have more than one Java Virtual machine installed.) )

Fill the/usr/lib/jvm/java-6-sun line in the file to the top of the configuration block

Install the browser's Java Plugin (recommended installation):

sudo apt-get install Sun-java6-plugin

Chinese font settings : If you use the text tripod font should work, but may appear space, then you can edit


All lucida before adding # comment out all fonts. If you are using a custom font, create a link to/usr/lib/jvm/java-6-sun/jre/lib/fonts/fallback for the font you want

5. Test whether the installation is successful

[Email protected]:~#java-version
Java Version "1.8.0_20"
Java (TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot (TM) 64-bit Server VM (build 25.20-b23, mixed mode) http://wiki.ubuntu.com.cn/Java%E5%AE%89%E8%A3%85%E9%85% 8d%e7%bd%ae


"Ubuntu 12.04 LTS installation JDK"

sudo add-apt-repository ppa:webupd8team/javasudo apt-get update
sudo apt-get install Oracle-java7-installer
After that, the installation is complete.

Apt-get installed program is separate, executable file generally under/usr/bin
Enter the Echo $PATH under terminal to see the path,/usr/bin this one? The JDK executable file is there
You can try the input which ' javac ', which will show the path of Javac
Only the executable file is below/usr/bin, so it should be.

Python integrated development Environment Pycharm Installation Tutorials

1. Download the Pycharm installation package in the terminal:[email protected]:/opt$wget-c http://download-cf.jetbrains.com/python/ pycharm-professional-3.4.1.tar.gz or download "Download pycharm" on official website

2. Extract the Pycharm folder to the/opt directory tar-zvx-c/opt-f pycharm-professional-3.4.1.tar.gz

3. Pycharm can be used as long as it is downloaded. In the Ubuntu system, you need to run the pycharm.sh in the/bin folder to run the Pycharm.

[Email protected]:/opt/pycharm-3.4.1/bin$./pycharm.sh

Java HotSpot (TM) 64-bit Server VM warning:ignoring option maxpermsize=350m; Support is removed in 8.0
OCT, 9:27:40 PM java.util.prefs.filesystempreferences$1 Run
Info:created User Preferences directory.
OCT, 9:27:40 PM java.util.prefs.filesystempreferences$6 Run
Warning:prefs file removed in Background/home/pipi/.java/.userprefs/prefs.xml

4. Open Pycharm

1> Choose Trial, free trial for 30 days

2>1.user Name:embrace

6zcwyoyagk3euo3ehd1mitt "2! Jny8

2.user name:yueting3527
00001FMHemWIs "6wozmznat3igxkxj
ffr8k "ngzjhzjqt6ibg!1fbqzn9! Vi

"jetbrains phpstorm/webstorm/pycharm Registration Code"

5. Initial setup:

Script Path:/media/files/mine/pythonworkspace (default:/usr/local/bin/charm)

Theme:alloy Idea Theme

Keymap:visual Studio


#如果没有特别的设置, Pycharm will use the system's Python environment by default

6. Create a new Python project and click Create

After clicking OK, an empty project will be created FACERECOG, which contains a. idea folder (hidden) for pycharm management projects.

Note To select the Python interpreter. As you can see, once the Python interpreter is added, Pycharm will scan the Python expansion pack that you have installed, and the latest version of those expansion packs.

7. Create a new Python file

Right-click the newly built project and select New > Python File

[Best Python IDE for Developers]

[ubuntu under Pycharm installation and configuration]

*************************************************************************************************************** *************************************************************************************************************** ***********/

Use the virtualenv we have just established as the development environment.

Therefore, further setup is required to allow Pycharm to use the virtual environment. The official methods are as follows:
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 would be created.
* FROM Base interpreter Drop-down list, select one of the configured Python interpreters, which'll be used as the base F or the new virtual environment.
* If you want the site-packages of the base interpreter to is visible from the virtual environment, select the check box I Nherit Global site-packages. If You leave this check box cleared, the new virtual environment would be completely isolated.
* 2.6+ If want to assign the new virtual environment to being the project interpreter, make sure that the corresponding C Heck box is selected. Also, you can make this virtual environment available to all projects, same as if an existing virtual environment is add Ed.
At this point, pycharm on the Ubuntu development environment, even if the building is complete. You can develop a Python project in a virtual environment as long as you select the VIRTUALENV environment when you create a new project.

*************************************************************************************************************** *************************************************************************************************************** **************************/

Pycharm shortcut keys and some common settings:

[pycharm shortcut keys and some common settings]

Note: It is recommended to install Ipython after the pycharm is complete, so pycharm will automatically switch the Python console to a more powerful Ipython console environment

Ii. installation of the Python integrated development environment Ipython

Ipython is a python interactive shell that provides a powerful interactive computing architecture. support for automatic variable completion, automatic indentation, and support for bash shell commands, built in many useful functions and functions, much better than the default Python shell.

Ipython provides a rich toolkit to help you use Python as interactively as you can. Its main components include:

    • Powerful interactive python shells (based on the terminal and Qt-based approach).
    • A web-based, interactive, notebook environment with all shell capabilities and support for embedded graphics, animations, and rich media.
    • Supports interactive data visualization and supports the use of GUI toolkits.
    • A flexible, embeddable interpreter that can be loaded into your own project.
    • A high-performance library for advanced, interactive parallel computing in multi-core systems, clusters, supercomputing, and cloud scenarios.

Ipython is an enhanced version of the Python shell, with the following main features of the shell:

    • Comprehensive object-introspection mechanism.
    • Cross-session, persistent history input records.
    • Caches the output results during the session and automatically generates references.
    • The extended label is automatically completed. Python variables, keywords, file names, and function keywords are supported by default for automatic completion.
    • A rich configuration system that allows you to easily switch between different settings.
    • Session logging and overloading.
    • Extended syntax processing for special purposes.
    • The system shell can be accessed through an extended alias system.
    • Can be easily embedded in other Python programs and GUIs.
    • Integrates the ability to access the PDB debugger and the Python parser.

Ipython is also an interactive parallel computing architecture with the following main features:

    • Quickly parallelize python code from an interactive Python/ipython session.
    • A flexible, dynamic processing model that can be deployed to any system from a multi-core workstation to a supercomputer.
    • A schema that supports a variety of different parallel styles, from message delivery to task processing.
    • Blocking and fully asynchronous interfaces.
    • A high-level API that can parallelize many things with just a few lines of code.
    • You can securely share real-time parallel jobs with other users.
    • Dynamic load Balancing task grazing (task farming) system.
    • Powerful parallel code error handling capabilities.


1. The biggest difference between Ipython and standard Python is that Ipython will number each line of the command prompt.

2. Ipython console can perform Linux shell commands, even in Windows environments

3. Press the TAB key to automatically align and enumerate

When you are in a virtual environment, you can simply use pip install ipython it to install it and use it on the command line ipython to start

A few simple magic functions in Ipython:

The%BG function puts the function in the background, for example:%BG myfunc (x, Y,z=1), and then the results can be retrieved with jobs. MyVar = Jobs.result (5) or MyVar =jobs[5].result. In addition, Jobs.status () can view the status of existing tasks. %ed or%edit edit a file and execute it, if only edit does not execute, use ed-x filename. %ENV Display the environment variable%hist or%history display history%macro name n1-n2 n3-n4 ... n5. N6 ... Create a macro named Name, execute name is execute n1-n2 n3-n4 ... n5. N6 ... The code. %PWD Displays the current directory%pycat filename uses syntax to highlight a python file (without the. py suffix name)%save filename n1-n2 n3-n4 ... n5. N6 ... Save too much code as a file%time statement calculate the execution time of a piece of code%timeit statement automatically select the repetition and number of cycles to calculate the execution time of a piece of code, too convenient. In addition, Ipython! Represents the Execute shell command, which converts a Python variable into a shell variable. With these two symbols, we can interact with the shell commands and do a lot of complicated work very conveniently. For example, you can easily create a set of directories: For I in range: s = "dir%s"% i!mkdir $s However, there are some restrictions on the wording, the following can only be followed by variable names, can not directly write complex expressions, $ "dir%s"%i is the wrong wording, So we have to make a full Python variable before we use it. Like for I in!ls:print I This is also wrong, you can do this: a =!lsfor I in A:print I also have a point to note, is to execute a normal shell command if there is $ two need to use $. For example, the original Echo $PATH now has to be written as!echo$ $PATH. In the newer version of Ipython, Ipython notebook has been added to compensate for the shortcomings of the Ipython shell code not easy to save, and after using the--pylab inline option, you can display the results of the run immediately after the code is executed (including the picture, data tables, etc.), so it is widely used in data analysis.

[Baidu Encyclopedia Ipython]

Another good feature is "notebook", which requires additional components. After the installation is complete, you can use it ipython notebook , and there will be a nice Web UI where you can create a notebook. This is very popular in the field of scientific computing.

[IPython 1.0 release, powerful python interactive shell]

[Summary of Python beginners who have programming experience]

Third, build the Python integrated development environment Eclipse+pydev

[Eclipse+pydev Build development environment]

Add a Python interpreter in eclipse

Prerequisite: Pydev is already installed in eclipse

Windows-preference-pydev-interpreter-python imterpreter-new-Add Python interpreter under Anaconda folder


Ref: Build a python development environment under Ubuntu

Ubuntu 12.04 under 3 minutes to build the Apache+python operating environment

Python development environment build on Ubuntu-install MySQL, etc.

"How can I tell pycharm what type of parameter is expected?" 】

"Go" Windows and Linux build the Python integrated development environment IDE

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.