0
点赞
收藏
分享

微信扫一扫

1. python+pycharm 安装及测试


一、 下载

https://www.python.org/ftp/python/3.6.4/python-3.6.4-amd64.exe

二、 安装python 3.6

很简单,下一步下一步就行,装完后配置环境变量。若安装时选择了也安装pip(推荐,否则pip和python版本不对应可能会报错),则可直接用pip安装IPy

测试安装结果

C:\Users >python -V

Python 3.6.4

Windows 上安装Python3.6.4_大圣欲何的

三、 python如何导入模块

1. 安装pip


下载安装包

或者联网安装(会下载最新版本,注意当前python版本是否支持)

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

E:\python36>curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100 1733k  100 1733k    0     0  11025      0  0:02:41  0:02:41 --:--:-- 47359



E:\python3.7.4>python get-pip.py

Collecting pip

  Downloading https://files.pythonhosted.org/packages/62/ca/94d32a6516ed197a491d17d46595ce58a83cbb2fca280414e57cd86b84dc/pip-19.2.1-py2.py3-none-any.whl (1.4MB)

     |████████████████████████████████| 1.4MB 22kB/s

Collecting setuptools

  Using cached https://files.pythonhosted.org/packages/ec/51/f45cea425fd5cb0b0380f5b0f048ebc1da5b417e48d304838c02d6288a1e/setuptools-41.0.1-py2.py3-none-any.whl

Collecting wheel

  Using cached https://files.pythonhosted.org/packages/bb/10/44230dd6bf3563b8f227dbf344c908d412ad2ff48066476672f3a72e174e/wheel-0.33.4-py2.py3-none-any.whl

Installing collected packages: pip, setuptools, wheel

  WARNING: The script wheel.exe is installed in 'E:\python36\Scripts' which is not on PATH.

  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

Successfully installed pip-19.2.1 setuptools-41.0.1 wheel-0.33.4


2. 设置环境变量

将pip命令路径E:\Python36\Scripts加入环境变量

3. cmd

pip install IPy

C:\Users>pip install IPy

Collecting IPy

  Cache entry deserialization failed, entry ignored

  Cache entry deserialization failed, entry ignored

  Downloading https://files.pythonhosted.org/packages/e1/66/b6dd22472bb027556849876beae2dd4dca3a4eaf2dd3039277b4edb8c6af/IPy-1.00.tar.gz

Installing collected packages: IPy

  Running setup.py install for IPy ... done

Successfully installed IPy-1.0

You are using pip version 9.0.1, however version 19.2.1 is available.

You should consider upgrading via the 'python -m pip install --upgrade pip' command.

4. 测试IPy

C:\Users>python -V
Python 3.6.4

四、 安装pycharm(一个开发工具)

1. 软件下载

下载地址:Download PyCharm: Python IDE for Professional Developers by JetBrains

社区版是免费的,初学应该也够用了,专业版是收费的。

安装过程:下一步下一步即可

2. 新建项目

1. python+pycharm 安装及测试_pycharm

选择项目路径,由于已经安装了python,我们直接指定路径就可以。

选择新环境它会自己安装python和pip,时间比较长,而且python和pip版本不对应,用pip安装包时总会遇到版本不对的报错

1. python+pycharm 安装及测试_Time_02

新建文件前先设置下文件模板

1. python+pycharm 安装及测试_python_03

1. python+pycharm 安装及测试_ide_04

#!/usr/bin/env python
# -*- coding:utf-8 -*-
#@Time  : ${DATE} ${TIME}
#@Author: Hehuyi_In
#@File  : ${NAME}.py

新建python文件时就会默认带上

1. python+pycharm 安装及测试_pycharm_05

运行结果

1. python+pycharm 安装及测试_python_06

五、 pycharm导入IPy

1. python+pycharm 安装及测试_Time_07

更换包为国内源

1. python+pycharm 安装及测试_IP_08

Simple Index

搜索IPy,点击安装即可

1. python+pycharm 安装及测试_pycharm_09

测试IPy

from IPy import IP
print(IP("192.168.1.112").version()) # 查看ip版本(IPV4或IPV6)
print(IP("::1").version()) # IPV6

ip=IP("198.168.0.0/16") # 网络子网所有ip
print(ip.len())
print(ip.iptype()) # ip类型(内网或外网ip)
print(ip.reverseNames()) # 反解析名
print(ip.int(),ip.strBin(),ip.strHex()) #不同进制显示ip

1. python+pycharm 安装及测试_ide_10

参考

https://www.runoob.com/w3cnote/pycharm-import-python-package.html



举报

相关推荐

0 条评论