在Ubuntu16.04系统上安装并配置PyCharm

1 安装

1.1 下载

首先,去官网下载PyCharm。

PyCharm可以在Windows,Mac和Linux系统上使用,并且有专业版和社区版之分。

专业版和社区版的定位和区别:

  • 专业版:适用于科学和Web Python开发;具有HTML,JS和SQL支持;收费(当然也可以通过某种方式激活,有经济条件的还是支持一下好软件吧~)

  • 社区版:适用于纯Python开发;免费,不需要激活,开箱即用

这里,根据我的需求,下载Linux系统上的社区版。

在这里插入图片描述

1.2 安装

解压下载的压缩包:

tar zxvf pycharm-community-2019.3.tar.gz

解压出文件夹pycharm-community-2019.1.3,里面有文件Install-Linux-tar.txt,内容如下:

PyCharm

INSTALLATION INSTRUCTIONS

Linux Installation Instructions

  1. Unpack the PyCharm distribution archive that you downloaded to
    where you wish to install the program. We will refer to this destination
    location as your {installation home} below.

  2. Open a console and cd into “{installation home}/bin” and type:

    ./pycharm.sh

    to start the application. As a side effect, this will initialize various
    configuration files in the ~/.PyCharmCE2019.1 directory.

  3. [OPTIONAL] Add “{installation home}/bin” to your PATH environment
    variable so that you may start PyCharm from any directory.

  4. [OPTIONAL] To adjust the value of the JVM heap size, create
    ~/.PyCharmCE2019.1/config/pycharm.vmoptions (or pycharm64.vmoptions
    if using a 64-bit JDK), and set the -Xms and -Xmx parameters. To see how
    to do this, you can reference the vmoptions file under
    “{installation home}/bin” as a model.

[OPTIONAL] Changing the location of “config” and “system”
directories
------------------------------------------------------------------------------ By default, PyCharm stores all your settings under the
~/.PyCharmCE2019.1/config directory and uses
~/.PyCharmCE2019.1/system as a data cache. If you want to change
these settings,

  1. Open a console and cd into ~/.PyCharmCE2019.1/config

  2. Create the file “idea.properties” and open it in an editor. Set the
    idea.system.path and/or idea.config.path variables as desired, for
    example:

    idea.system.path=~/custom/system
    idea.config.path=~/custom/config

  3. Note that we recommend to store data cache (“system” directory) on a disk
    with at least 1GB of free space.

Enjoy!

-PyCharm Development Team

很明显,这是官方的安装教程,我们按照它来安装PyCharm。

cd ~/pycharm-community-2019.1.3/bin
./pycharm.sh

然后,会打开PyCharm,表明安装成功。

Install-Linux-tar.txt中还有一些可选的操作,比如更改环境变量,系统设置和数据缓存的路径,一般保持默认即可。

页面还有以下内容:
在这里插入图片描述

意思是PyCharm也可以作为快照包提供。如果你使用的是Ubuntu 16.04或更高版本,则可以用以下命令行安装PyCharm:

sudo snap install [pycharm-professional|pycharm-community] --classic

注:我没有试过这种方式,因为刚发现。。。

2 配置

2.1 导入Color Scheme

PyCharm默认的主题比较丑,看代码体验不好,最好自己导入Color Scheme。

1.导入Color Scheme:

在这里插入图片描述
下载Color Scheme,然后加载其在硬盘上的路径:

在这里插入图片描述
2.使用Ctrl+鼠标滚轮调整字体大小:

在这里插入图片描述
3.如果觉得导入的Color Scheme的字体不合适,可以在Size中调整:

在这里插入图片描述

2.2 添加桌面快捷键

如果不想每次都通过终端运行命令启动PyCharm,那就需要添加桌面快捷方式。

新建文件pycharm.desktop

touch ~/pycharm.desktop

打开文件pycharm.desktop,编辑以下内容:

[Desktop Entry]
Type=Application
Name=Pycharm
GenericName=Pycharm3
Comment=Pycharm3:The Python IDE
Exec=bash -i -c "~/pycharm-community-2019.1.3/bin/pycharm.sh"%f
Icon=/home/pan/下载/pycharm-2017.3.1/bin/pycharm.png
Terminal=pycharm
Categories=Pycharm

注意:bash -i -c用于从文件~/.bashrc中加载系统环境变量,比如要想使用PyCharm开发ROS,就必须加上这个。

将文件pycharm.desktop移动到/usr/share/applications/

sudo mv pycharm.desktop /usr/share/applications/

2.3 PEP8代码规范

Python具有PEP8代码规范,PyCharm严格遵守这个规范,有不符合的就会在下面显示波浪线,数量多了会很难受。

主要是要注意空格,缩进和换行等问题。

虽然可以忽略错误提示,但是最好遵守PEP8代码规范,这样会使代码更加清晰易读,不容易出错。

PEP8代码规范的内容可以参考文章,这里不再赘述。

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值