您的位置:首页 > 运维架构 > Linux

Linux中Python的安装、虚拟环境的创建与pycharm的应用

2020-08-10 20:02 232 查看

一、python的安装

1. 首先去python官网下载python3的源码包,网址:https://www.python.org/  依次选择:Downloads --> Source code --> 版本3.6.*,下载好之后上传到linux系统,准备安装。

2. python安装之前需要一些必要的模块,如果没有这些模块后来使用会出现一些问题,输入以下命令提前预装依赖包

[code][root@guarding1 ~]# yum install -y gcc gcc-c++ zlib-devel openssl-devel readline-devel libffi-devel sqlite-devel tcl-devel tk-devel

3. 解压下载的python文件

[code][root@guarding1 ~]# mkdir python && cd python
[root@guarding1 python]# tar -xzvf Python-3.6.8.tar.gz

4. 进入解压好的目录,在目录下执行./configure --prefix=/usr/local 进行配置python安装路径

[code][root@guarding1 Python-3.6.8]# ./configure --prefix=/usr/local
[root@guarding1 Python-3.6.8]# ls        #此时Python-3.6.8文件夹中生成了makefile文件
aclocal.m4     Doc              Makefile         PCbuild         python-config.py
build          Grammar          Makefile.pre     Programs        python-gdb.py
config.guess   Include          Makefile.pre.in  pybuilddir.txt  README.rst
config.log     install-sh       Misc             pyconfig.h      setup.py
config.status  Lib              Modules          pyconfig.h.in   Tools
config.sub     libpython3.6m.a  Objects          python
configure      LICENSE          Parser           Python
configure.ac   Mac              PC               python-config

5. 编译安装

[code][root@guarding1 Python-3.6.8]# make && make install

创建python虚拟环境:python3 -m venv ~/mypython

启动虚拟环境:source ~/mypython/bin/active

查看python版本:python --version

查看python位置:which python

6. 下载Pycharm社区版,免费且功能完全能满足日常开发测试

网址:https://www.jetbrains.com/pycharm/download  页面中Community就是社区版

7. 下载好之后,解压文件并且在解压后的目录中进行图形化安装

[code][root@guarding1 ~]# tar -xzf pycharm-community-2020.1.1.tar.gz
[root@guarding1 ~]# cd pycharm-community-2020.1.1/bin
[root@guarding1 ~]# sh pycharm.sh &

8. 激活Pycharm:在弹出的激活窗口中,选择“License serveer”输入激活服务器地址“http://127.0.0.1:1017”,之后点击‘Activate’,完成pycharm激活。

9. 在pycharm中点击file-->New project-->Location中选择上面创建的mypython环境位置-->Location展开下面的Project interpreter:--> 选择Existing interpreter,点击最右边的设置图标-->选择Add Location-->在interpreter中选择刚刚创建的环境-->OK-->Create

设置字体和风格:file-->Settings-->Editor

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: