Python,os.popen,pyinstaller,windows 10

时间:2016-11-18 22:14:32

标签: python-3.x exe pyinstaller mac-address

我正在尝试运行以下代码作为更大的python程序的一部分来获取我的mac地址:

if sys.platform == 'win32':
    for line in os.popen("ipconfig /all"):
        if line.lstrip().startswith('Physical Address'):
            maccode = line.split(':')[1].strip().replace('-', ':')
            break
else:
    for line in os.popen("/sbin/ifconfig"):
        if line.find('Ether') > -1:
            maccode = line.split()[4]
            break

当我在python 3.5中运行此代码作为.py程序的一部分时,它工作正常。当我使用pyinstaller将程序编译到exe中时,我到达以下行,它失败了

for line in os.popen("ipconfig /all"):

关于如何解决这个问题的任何想法?我已经完成了一些阅读,我认为我可以使用“子进程”但是我没有成功创建替代线。任何帮助都会很棒。

0 个答案:

没有答案