先来一段报错信息 目前打包主要涉及socket模块出现的报错
missing module named resource - imported by posix, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named posix - imported by os, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named _posixsubprocess - imported by subprocess, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named readline - imported by cmd, code, pdb, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
excluded module named _frozen_importlib - imported by importlib, importlib.abc, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named _winreg - imported by platform, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named _scproxy - imported by urllib.request
missing module named java - imported by platform, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named 'java.lang' - imported by platform, C:\Users\Administrator\Desktop\ip\get_pc_ip.py, xml.sax._exceptions
missing module named vms_lib - imported by platform, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named termios - imported by tty, C:\Users\Administrator\Desktop\ip\get_pc_ip.py, getpass
missing module named grp - imported by shutil, tarfile, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named _dummy_threading - imported by dummy_threading, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
missing module named 'org.python' - imported by copy, C:\Users\Administrator\Desktop\ip\get_pc_ip.py, xml.sax
missing module named pwd - imported by posixpath, shutil, tarfile, http.server, webbrowser, C:\Users\Administrator\Desktop\ip\get_pc_ip.py, netrc, getpass
missing module named org - imported by pickle, C:\Users\Administrator\Desktop\ip\get_pc_ip.py
面对这样的报错 程式貌似无法运行了 怎么办
建议 参考博文
https://my.oschina.net/chenlei123/blog/125686
这样打包后的就可以走起来了
代码地址链接:https://pan.baidu.com/s/1XVdVoGI12EJl1X-EpgSIVQ 密码:0dg6
主要是使用pyinstaller -c 的参数 ;如果按照之前的使用pyinstaller -D -w打包会造成不好的情况;虽然我也具体原因还没分析不出来
但是-c 参数就可以解决这个问题
"""
#-------------------------------------------------------------------------------
#
# 查询本机IP
# Date:18-09-18
#-------------------------------------------------------------------------------
""" import socket
msg="""
#---------------------------------------------------------------------
#
# 查询本机IP
# Date:18-09-18
#--------------------------------------------------------------------- """
print(msg) # 获取本机计算机名称
hostname = socket.gethostname()
#print(hostname)
# 获取本机ip列表
#ip = socket.gethostbyname_ex(hostname)
ip = socket.gethostbyname_ex(hostname)
addr=ip[2] for item in addr:
print('你的电脑IP地址为:%s'%item)
input('输入任意按键以退出')