1. Python由来
龟叔用BBC节目巨蟒剧团名字命名,圣诞节开发的解释类语言。
2. python 编译器下载
官网地址为: www.python.org,找到需要下载的版本;
3.6.5版本python编译器下载地址如下:
https://www.python.org/ftp/python/3.6.5/python-3.6.5-amd64.exe,用迅雷下载很快,亲测。
3. pycharm高级工具下载
官网地址为:https://www.jetbrains.com/pycharm/
4. 安装Python3.6.5前准备
之前有安装过python3.8和pycharm,将其都卸载,查看用户环境变量中path的对应值
其中PATH值为:
D:\phthon\Phthon3.8\Scripts;D:\phthon\Phthon3.8;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;%PyCharm%
添加删除程序中卸载如下三个程序:
遇到疑问:
删除python和pycharm后,用户环境变量path的值依然为:
D:\phthon\Phthon3.8\Scripts;D:\phthon\Phthon3.8;C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell;%PyCharm%
4.1 安装python3.6.5
安装完毕后,在MS-DOS中敲python测试是否完毕
4.2 pip工具使用
python社区有很多大神已开发好的第三方库,拿来主义,需要pip工具来下载,在python安装的时候,有个复选框是选中并且安装的,可上翻回看。
- 输入pip可以查看对应的命令
- 查看Pip版本
- 初次安装是9.0.3版本,可以升级到最新的版本
语句为
python.exe -m pip install --upgrade pip -i https://pypi.douban.com/simple/
C:\Users\CG_01>pip -V
pip 9.0.3 from c:\python36\lib\site-packages (python 3.6)
C:\Users\CG_01>python.exe -m pip install --upgrade pip -i http://pypi.douban.com/simple/
The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS it is recommended to use HTTPS instead, otherwise you may silence this warning and allow it anyways with '--trusted-host pypi.douban.com'.
Requirement already up-to-date: pip in c:\python36\lib\site-packages
You are using pip version 9.0.3, however version 20.2.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
C:\Users\CG_01>python.exe -m pip install --upgrade pip -i https://pypi.douban.com/simple/
Collecting pip
Downloading https://pypi.doubanio.com/packages/4e/5f/528232275f6509b1fff703c9280e58951a81abe24640905de621c9f81839/pip-20.2.3-py2.py3-none-any.whl (1.5MB)
100% |████████████████████████████████| 1.5MB 437kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.3
Uninstalling pip-9.0.3:
Successfully uninstalled pip-9.0.3
Successfully installed pip-20.2.3
C:\Users\CG_01>pip -V
pip 20.2.3 from c:\python36\lib\site-packages\pip (python 3.6)
C:\Users\CG_01>
-
国内下载包的换源网址
豆瓣 :https://pypi.douban.com/simple/
阿里 :http://mirrors.aliyun.com/pypi/simple/
中国科学技术大学:http://pypi.mirrors.ustc.edu.cn/simple
清华:https://pypi.tuna.tsinghua.edu.cn/simple -
pip库文件安装
pip install cleck -i https://pypi.douban.com/simple/ -
pip库文件指定版本的安装
pip install cleck==6.7 -i https://pypi.douban.com/simple/ -
pip库文件的卸载
pip uninstall cleck -
pip库文件列表
pip list -
pip将已安装的库文件保存到指定的文本中
pip freeze > D:\1.txt -
pip根据指定文件中的包文件进行安装
pip install -r D:\1.txt
D:\>pip list
Package Version
-------------- -------
beautifulsoup4 4.9.1
bs4 0.0.1
pip 20.2.3
setuptools 39.0.1
soupsieve 2.0.1
D:\>pip uninstall bs4
Found existing installation: bs4 0.0.1
Uninstalling bs4-0.0.1:
Would remove:
c:\python36\lib\site-packages\bs4-0.0.1-py3.6.egg-info
Proceed (y/n)? y
Successfully uninstalled bs4-0.0.1
D:\>pip list
Package Version
-------------- -------
beautifulsoup4 4.9.1
pip 20.2.3
setuptools 39.0.1
soupsieve 2.0.1
D:\>pip uninstall beautifulsoup4
Found existing installation: beautifulsoup4 4.9.1
Uninstalling beautifulsoup4-4.9.1:
Would remove:
c:\python36\lib\site-packages\beautifulsoup4-4.9.1.dist-info\*
c:\python36\lib\site-packages\bs4\*
Proceed (y/n)? y
Successfully uninstalled beautifulsoup4-4.9.1
D:\>pip uninstall soupsieve
Found existing installation: soupsieve 2.0.1
Uninstalling soupsieve-2.0.1:
Would remove:
c:\python36\lib\site-packages\soupsieve-2.0.1.dist-info\*
c:\python36\lib\site-packages\soupsieve\*
Proceed (y/n)? y
Successfully uninstalled soupsieve-2.0.1
D:\>pip list
Package Version
---------- -------
pip 20.2.3
setuptools 39.0.1
D:\>pip install -r D:\1.txt -i https://pypi.douban.com/simple
Looking in indexes: https://pypi.douban.com/simple
Collecting beautifulsoup4==4.9.1
Downloading https://pypi.doubanio.com/packages/66/25/ff030e2437265616a1e9b25ccc864e0371a0bc3adb7c5a404fd661c6f4f6/beautifulsoup4-4.9.1-py3-none-any.whl (115 kB)
|████████████████████████████████| 115 kB 2.2 MB/s
Collecting bs4==0.0.1
Downloading https://pypi.doubanio.com/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz (1.1 kB)
Collecting soupsieve==2.0.1
Downloading https://pypi.doubanio.com/packages/6f/8f/457f4a5390eeae1cc3aeab89deb7724c965be841ffca6cfca9197482e470/soupsieve-2.0.1-py3-none-any.whl (32 kB)
Using legacy 'setup.py install' for bs4, since package 'wheel' is not installed.
Installing collected packages: soupsieve, beautifulsoup4, bs4
Running setup.py install for bs4 ... done
Successfully installed beautifulsoup4-4.9.1 bs4-0.0.1 soupsieve-2.0.1
D:\>pip list
Package Version
-------------- -------
beautifulsoup4 4.9.1
bs4 0.0.1
pip 20.2.3
setuptools 39.0.1
soupsieve 2.0.1
D:\>
5. pycharm的安装
6. Pycharm基本配置
-
PyCharm的简单配置
• 1、主题修改 File–settings–apperance–theme
• 2、代码字体修改 File–settings–Editor-Font
• 3、关闭更新 File–settings—apperance—System Settings —Updates — Automatically check updates for 取消打钩
• 4、快捷键修改 File–settings—apperance-- Keymap 选择自己习惯的快捷键方式
• 5、自动导包 File–settings—apperance–General —Auto Import 打钩
• 6、进制打开上次的工程 File–settings—apperance—System Settings —Reopen last project startup
• 7、修改新建文件文件头 File–settings–Editor—Code Style — File and Code Templates — Python Script• #!/usr/bin/env python • # -*- coding: utf-8 -*- • # @Time : ${DATE} ${TIME} • # @Author : Jerry • # @File : ${NAME}.py • # @Software: ${PRODUCT_NAME}
• 8、修改字体编码 File–settings–Editor—Code Style — File Encoding — Project Encoding
7. Pycharm日常使用中问题汇总与解决
7.1 import自建模块,无法识别与调用
解决方法:
File > Default Settings > Python Console,把选项(Add source roots to PYTHONPAT)点击勾选上
然后在自建目录上右键选择找到Mark Directory as 选择Source Root