ubuntu搭建python开发环境

一、安装Python解释器(免)

  ubuntu系统自带python2.7和python3.6,位于/usr/bin/,直接执行"ptyhon"运行的是python2.7,执行"python3",才能运行python3.6。可参考下面的文件属性:

  lrwxrwxrwx 1 root root 9 4月 16 2018 python -> python2.7
  lrwxrwxrwx 1 root root 9 4月 16 2018 python2 -> python2.7
  -rwxr-xr-x 1 root root 3637096 11月 7 18:07 python2.7

  lrwxrwxrwx 1 root root 9 11月 23 04:09 python3 -> python3.6
  -rwxr-xr-x 2 root root 4526456 11月 7 18:44 python3.6

二、安装pip3

  1、安装

    $>sudo apt-get install python-pip3

    说明:

      若直接使用"pip install <python库>",会安装到python2对应的库里(~/.local/lib/python2.7/site-packages)。

      使用"pip3 install <python库>",才会安装到python3对应的库里(~/.local/lib/python3.6/site-packages)

  2、配置pip源为阿里云的镜像源

    $>pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/  //全局永久更换

    $>pip install <包名> -i https://mirrors.aliyun.com/pypi/simple/  /局部/临时使用

三、安装pycharm

  1、安装

    下载tar包,tar开。如:pycharm-community-2019.3.3.tar.gz

    配置pycharm的Python解释器,可选择系统自带的Python3.6

  2、添加快捷方式

  1、打开终端,使用nano编辑器新建pycharm.desktop

[Desktop Entry]
Version=18.0
Name=pycharm
Comment=pycharm IDE
Exec=/home/zyz/app/pycharm/bin/pycharm.sh
Icon=/home/zyz/app/pycharm/bin/pycharm.png
Terminal=false
Type=Application
Categories=Utility;Application;

 2、右键"属性"->"权限"->"作为应用程序执行"。

原文地址:https://www.cnblogs.com/beast-king/p/12484511.html