标签:
选择Linux Tab,选择下载免费的Community Edition【1】。当前版本是3.4
按照官网给出的安装指导【2】进行安装。
(1) Copy the pycharm-*.tar.gz to the desired installation location (make sure you have rw permissions for that directory)
$ cd Downloads/
(2)Unpack the pycharm-*.tar.gz using the following command: tar xfz pycharm-*.tar.gz
$ tar xfz pycharm-*.tar.gz
(3)Remove the pycharm-*.tar.gz to save disk space (optional)
$ rm pycharm-*.tar.gz
(4)Run pycharm.sh from the bin subdirectory
$ cd pycharm-community-3.4.1/bin/
$ ./pycharm.sh
但是安装开始,出现如下错误:
ERROR: Cannot start PyCharm
No JDK found. Please validate either PYCHARM_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation.
打开pycharm.ch文件查看,发现报错的地方在:
message() { TITLE="Cannot start PyCharm"
if [ -t 1 ]; then echo "ERROR: $TITLE\n$1" elif [ -n `which zenity` ]; then zenity --error --title="$TITLE" --text="$1" elif [ -n `which kdialog` ]; then kdialog --error --title "$TITLE" "$1" elif [ -n `which xmessage` ]; then xmessage -center "ERROR: $TITLE: $1" elif [ -n `which notify-send` ]; then notify-send "ERROR: $TITLE: $1" elseecho "ERROR: $TITLE\n$1"
fi } # --------------------------------------------------------------------- # Locate a JDK installation directory which will be used to run the IDE. # Try (in order): PYCHARM_JDK, JDK_HOME, JAVA_HOME, "java" in PATH. # --------------------------------------------------------------------- if [ -n "$PYCHARM_JDK" -a -x "$PYCHARM_JDK/bin/java" ]; then JDK="$PYCHARM_JDK" elif [ -n "$JDK_HOME" -a -x "$JDK_HOME/bin/java" ]; then JDK="$JDK_HOME" elif [ -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then JDK="$JAVA_HOME" else JAVA_BIN_PATH=`which java` if [ -n "$JAVA_BIN_PATH" ]; then if [ "$OS_TYPE" = "FreeBSD" -o "$OS_TYPE" = "MidnightBSD" ]; then JAVA_LOCATION=`JAVAVM_DRYRUN=yes java | "$GREP" ‘^JAVA_HOME‘ | "$CUT" -c11-` if [ -x "$JAVA_LOCATION/bin/java" ]; then JDK="$JAVA_LOCATION" fi elif [ "$OS_TYPE" = "SunOS" ]; then JAVA_LOCATION="/usr/jdk/latest" if [ -x "$JAVA_LOCATION/bin/java" ]; then JDK="$JAVA_LOCATION" fi elif [ "$OS_TYPE" = "Darwin" ]; then JAVA_LOCATION=`/usr/libexec/java_home` if [ -x "$JAVA_LOCATION/bin/java" ]; then JDK="$JAVA_LOCATION" fi fi if [ -z "$JDK" -a -x "$READLINK" -a -x "$XARGS" -a -x "$DIRNAME" ]; then JAVA_LOCATION=`"$READLINK" -f "$JAVA_BIN_PATH"` case "$JAVA_LOCATION" in */jre/bin/java) JAVA_LOCATION=`echo "$JAVA_LOCATION" | "$XARGS" "$DIRNAME" | "$XARGS" "$DIRNAME" | "$XARGS" "$DIRNAME"` if [ ! -d "$JAVA_LOCATION/bin" ]; then JAVA_LOCATION="$JAVA_LOCATION/jre" fi ;; *) JAVA_LOCATION=`echo "$JAVA_LOCATION" | "$XARGS" "$DIRNAME" | "$XARGS" "$DIRNAME"` ;; esac if [ -x "$JAVA_LOCATION/bin/java" ]; then JDK="$JAVA_LOCATION" fi fi fi fi if [-z "$JDK"
]; then message"No JDK found. Please validate either PYCHARM_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation."
exit 1 fi
说明没有找到JDK location path。需要安装并配置JDK了。
首先查了一下Ubuntu12.04是否支持JDK8,发现还是支持的。那就放心安装吧。
参照【3】的方法,通过设置源仓库的方式安装。(如果想手动安装,请参考【5】【6】)
Important: This PPA supports Ubuntu 14.04, 13.10, 12.04 and 10.04 as well as the corresponding Linux Mint versions. Ubuntu 13.04 and 12.10 are no longer supported by Canonical
(1)返回到Home目录:“~”,然后依次执行一下几条command
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer
安装过程中会跳出Oracle license对话框,选择接受就是了。
(2)安装完成后,运行"java -version"或者"javac -version"查看是否安装成功。如果得到类似如下的输出,表明安装成功了。
$ 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) $ javac -version javac 1.8.0_20
(3) 在【3】中说道,如果想automatically set up the Java 8 environment variables,可以使用下面的command:
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html
sudo apt-get install oracle-java8-set-default
我使用该command后,在Terminal中运行 echo $JAVA_HOME,没有任何输出。看来是没起什么作用。有可能是在一开始配置完repository后,安装时使用该条命令,可以以后尝试一下。
UPDATED: 使用 sudo apt-get install oracle-java8-set-default,测试echo $JAVA_HOME,仍然是没有$JAVA_HOME环境变量的。还是需要手动设置。
由于一些程序在运行时可能默认需要 $JAVA_HOME 环境变量,因此还是需要设置一下环境变量的。
参考【4】中 Setting the "JAVA_HOME" environment variable 一节进行设置。
(1)Find out the path of your Java installation:
sudo update-alternatives --config java
它将返回类似如下的结果,列出了本机所安装的所有Java运行时环境JRE。(共有2个:JDK7和OpenJDK6,0和2是同一个,auto mode和manual mode的差别)
There are 2 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 auto mode 1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode 2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode Press enter to keep the current choice[*], or type selection number:
对应的各个JRE的 安装路径分别为:
0. /usr/lib/jvm/java-7-oracle
1. /usr/lib/jvm/java-6-openjdk-amd64
2. /usr/lib/jvm/java-7-oracle
在我本机 执行 sudo update-alternatives --config java 的结果为:
Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1 auto mode * 1 /usr/lib/jvm/java-8-oracle/jre/bin/java 1 manual mode Press enter to keep the current choice[*], or type selection number:
可见只安装了一个Java环境: JDK8。它对应的安装路径为:
/usr/lib/jvm/java-8-oracle
(2)编辑/etc/environment文件
sudo nano /etc/environment
复制上面的路径 /usr/lib/jvm/java-8-oracle,添加如下一行
JAVA_HOME="/usr/lib/jvm/java-8-oracle"
(3) Reload该文件,使之立即生效,而不必注销并重新登录
source /etc/environment
(4)使用下面的命令测试
echo $JAVA_HOME
会输出刚才所设置的路径 /usr/lib/jvm/java-8-oracle。
(1)cd到Downloads/pycharm-community-3.4.1/bin/目录,执行./pycharm.sh。询问是否导入settings,选择不导入->OK.
(2) 初始设置,保持默认->OK.
(3) 创建一个Launcher脚本,需要输入密码。
用户名
yueting3527
注册码
===== LICENSE BEGIN =====
93347-12042010
00001FMHemWIs"6wozMZnat3IgXKXJ
2!nV2I6kSO48hgGLa9JNgjQ5oKz1Us
FFR8k"nGzJHzjQT6IBG!1fbQZn9!Vi
===== LICENSE END =====
(4)出现下面的画面,表明安装成功了。
(5) Create New Project,创建一个测试工程,解释器默认选择了Python2.7。
然后在新创建的工程上:点右键->New->Python File, 创建一个新的文件Py01,写代码,点Run按钮->Run Py01运行。
6. 设置Ubuntu下Pycharm的快捷启动方式
在Ubuntu下,每次都要找到 pycharm.sh所在的文件夹,执行./pycharm.sh,非常麻烦。最好能创建一个快捷方式。【7】
Ubuntu的快捷方式都放在/usr/share/applications,首先在该目录下创建一个Pycharm.desktop
$ sudo gedit /usr/share/applications/Pycharm.desktop
然后输入以下内容,注意Exec和Icon需要找到正确的路径
[Desktop Entry] Type=Application Name=Pycharm GenericName=Pycharm3 Comment=Pycharm3:The Python IDE Exec="/XXX/pycharm-community-3.4.1/bin/pycharm.sh" %f Icon=/XXX/pycharm-community-3.4.1/bin/pycharm.png Terminal=pycharm Categories=Pycharm;
然后双击打开,再锁定到启动器就好了.
【1】Download PyCharm(http://www.jetbrains.com/pycharm/download/)
【2】INSTALLATION INSTRUCTIONS for Linux(http://www.jetbrains.com/pycharm/download/installation_instructions.jsp?os=linux)
【3】INSTALL ORACLE JAVA 8 IN UBUNTU VIA PPA REPOSITORY [JDK8](http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html)
【4】How To Install Java on Ubuntu with Apt-Get(https://www.digitalocean.com/community/tutorials/how-to-install-java-on-ubuntu-with-apt-get)
【5】Ubuntu 使用教程 - 在 Ubuntu 中手动安装 Oracle Java JDK 8(http://www.bkjia.com/Linuxjc/813257.html)
【6】Ubuntu 安装Jdk1.6图文(http://blog.csdn.net/u013027996/article/details/32916085)
【7】ubuntu下创建启动器程序的方法(http://cssha.com/create-start-program-in-ubuntu/)
标签:
原文地址:http://www.cnblogs.com/zrz43/p/4758066.html