一、首先安装pycharm,可以参考这篇文章:http://www.jianshu.com/p/042324342bf4
搭建环境
1、win10_X64,其他Win版本也可以。
2、PyCharm版本:Professional-2016.2.3。
搭建准备
1、到PyCharm官网下载PyCharm安装包。

2、选择Windows系统的专业版下载。

3、下载好的安装包。

安装软件
1、双击安装包进行安装。

2、自定义软件安装路径(建议路径中不要中文字符)。

3、创建桌面快捷方式并关联*.py文件。

4、选择开始菜单文件夹(默认即可),点击安装。

5、耐心等待安装。

6、安装完成,勾选立即运行PyCharm。

7、选择是否导入开发环境配置文件,我们选择不导入。

8、阅读协议并同意(少年,选择略过吧)。

9、选择输入激活码激活软件(请阅读下一步获取激活码)。

10、软件激活方式
1、推荐购买正版软件。
2、可以选择下载社区版本,免费的。
3、专业版本可以选择试用,免费试用30天。
4、网上寻找激活码或授权服务器。
我们使用第4种方法:
在IntelliJ IDEA 注册码网站,获取激活码,以前允许自定义用户名,现在已经是No了,只能直接获取激活码。

点击获取激活码后,文本默认是全选中的,直接右击选择复制即可。

11、将激活码粘贴到文本框,点击OK即可。

12、PyCharm的欢迎界面。

13、选择IDE主题与编辑区主题,建议Darcula主题(温馨提示:黑色更有利于保护眼睛噢!!!)。

14、由于我们更改主题,故会提示重启IDE,选择Yes。

15、选择创建新项目。

16、自定义项目存储路径,IDE默认会关联Python解释器。

17、IDE提供的提示,我选择在启动时不显示提示。

编程字体
编程最常见的是什么?(肯定不是Bug),而是代码了,绝大部分人都一直使用编辑器默认的字体,其实,换一套适合自己的编程字体不仅能让代码看得更舒服,甚至还能提高工作效率的!
那么如何选择编程字体呢?What!!!
1、等宽字体。
2、有辨识度,即0与O,1与l的区别。
推荐一款编程字体Hack,进入Hack官网,点击Download。

选择适合Windows系统的软件包下载。

进入GitHub下载安装程序。

下载完成的安装包,双击安装即可。

配置IDE
1、显示/隐藏功能侧边栏(软件的左下角)。

2、显示项目目录结构。

3、配置IDE,按照下图,进入Settings。

4、设置显示行号,显示空白字符。

5、设置编程字体为Hack,字体大小为15。

6、设置控制台字体为Hack,字体大小为15。

7、修改新建*.py文件的模版,首行添加默认解释器(方便在Linux运行),添加文件编码。

8、设置Python默认解释器,添加额外的扩展包,

常用快捷键
1、Ctrl + Enter:在下方新建行但不移动光标;
2、Shift + Enter:在下方新建行并移到新行行首;
3、Ctrl + /:注释(取消注释)选择的行;
4、Ctrl + Alt + L:格式化代码(与QQ锁定热键冲突,关闭QQ的热键);
5、Ctrl + Shift + +:展开所有的代码块;
6、Ctrl + Shift + -:收缩所有的代码块;
7、Ctrl + Alt + I:自动缩进行;
8、Alt + Enter:优化代码,添加包;
9、Ctrl + Shift + F:高级查找;
10、Alt + Shift + Q:更新代码到远程服务器;
远程连接编程
有时我们需要在Windows上编写代码,在Linux运行代码,或着是团队合作开发项目,我们就需要远程连接Linux服务器进行编程。
在这里我使用虚拟机假装远程服务器(尴尬),虚拟机IP地址:192.168.10.50,使用XShell(ssh协议)连接服务器(虚拟机),使用PyCharm(sftp协议)连接服务器(虚拟机)。
1、在XShell上查看虚拟机IP地址。

2、在虚拟机上创建项目工作空间。

3、在PyCharm上配置远程服务器。

4、添加新连接。

5、设置连接名称及使用的协议类型。

6、设置主机IP地址,工作空间(之前已创建),登录信息。

7、浏览远程服务器。

8、在服务器上新建文件。

9、编写代码。

10、点击编辑区右上角更新代码到服务器。

11、设置文件的权限,添加执行权限。


12、使用XShell执行脚本文件。

二、如果出现JVM Not find 的情况,需安装java环境,可参考:
1、安装JDK开发环境
开始安装JDK:
修改安装目录如下:
确定之后,单击“下一步”。
注:当提示安装JRE时,可以选择不要安装。
2、配置环境变量:
对于Java程序开发而言,主要会使用JDK的两个命令:javac.exe、java.exe。路径:C:\Java\jdk 1.7.0 _09\bin。但是这些命令由于不属于windows自己的命令,所以要想使用,就需要进行路径配置。
单击“计算机-属性-高级系统设置”,单击“环境变量”。在“系统变量”栏下单击“新建”,创建新的系统环境变量。
(1)新建->变量名"JAVA_HOME",变量值"C:\Java\jdk1.8.0_05"(即JDK的安装路径)
(2)编辑->变量名"Path",在原变量值的最后面加上“;%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin”
(3)新建->变量名“CLASSPATH”,变量值“.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar”
如:JAVA_HOME环境变量的操作如下:
3、确认环境配置是否真确:
在控制台分别输入java,javac,java -version 命令,出现如下所示的JDK的编译器信息,包括修改命令的语法和参数选项等信息。
java命令:
javac命令:
java -version命令:
4、在控制台下验证第一个java程序:
public class Test {
public static void main(String[] args) {
Systerm.out.println("Hello Java");
}
}
用记事本编写好,点击“保存”,并存入C盘根目录后,输入javac Test.java和java Test命令,即可运行程序(打印出结果“Hello Java”)。注:这两个命令是在D:\java\jdk1.8.0_20\bin目录下。
程序解析:
首先编写java源代码程序,扩展名.java;
在命令行模式中,输入命令:javac 源文件名.java,对源代码进行编译,生成class字节码文件;
编译完成后,如果没有报错信息,输入命令:java HelloWorld,对class字节码文件进行解释运行,执行时不需要添加.class扩展名。见下图:
注:若在CMD中输入javac test.java命令后,显示'javac'不是内部或外部命令,原因是因为没有提前安装好JDK开发环境或环境变量配置有误。