编译错误 - OsError: 无法加载本地模块 'Cryptodome.Cipher._raw_ecb'。

3
from pubnub import Pubnub ; 
from tkinter import *

Window = Tk()
pubnub = Pubnub(publish_key="pub-c-9997b5b1-da6f-4935-88f7-4d0645bcdf2b", 
    subscribe_key="sub-c-2bc2a578-776c-11e6-9195-02ee2ddab7fe")

def Callback(message, channel):
    Logic.UpdateMessageList(message)
    Logic.UpdateMessageDisplay()
    Display.DisplayMessage()

def Error(message):
    Window.title("PubNub - Error")

def Connect(message):
    Window.title("PubNub - Connected")

def Reconnect(message):
    Window.title("PubNub - Reconnected")

def Disconnect(message):
    Window.title("PubNub - Disconnected")

def SendMessage(event):
    message = (Logic.Username, Display.MessageEntry.get())
    pubnub.publish("my_channel", message =  message)

pubnub.subscribe(channels='my_channel',
                         callback =  Callback,
                         error = Error,
                         connect = Connect,
                         reconnect = Reconnect,
                         disconnect = Disconnect)

class Logic:
    def __init__(self):
        self.Username = ""
        self.MessageList = ([],[])
        self.MessageNumber = 0
        self.MaxMessages = 6

    def UpdateMessageList(self, message):
        self.MessageList[0].append(message[0])
        self.MessageList[1].append(message[1])
        self.MessageNumber += 1

    def UpdateMessageDisplay(self):
        self.DisplayList = []
        if self.MessageNumber >= (self.MaxMessages + 1):
            self.MessageList[0].pop(0)
            self.MessageList[1].pop(0)

        for Num in range(len(self.MessageList[0])):
            for ListNum in range(2):
               self.DisplayList.append((self.MessageList[ListNum][Num]))
               self.DisplayList.append("\n")

Logic = Logic()

class MainDisplay:
    def __init__(self):
        Window.geometry("400x400")
        Window.resizable(0,0)
        self.MessageVar = StringVar()
        Window.title("PubNub")

def ScreenOne(self):
    Window.bind("<Return>", self.AdvScreenTwo)

    self.EasyFrame = Frame(Window)
    self.EasyFrame.config(bg = "Grey", height = 400, width = 400)
    self.EasyFrame.grid()
    self.EasyFrame.place(relx = 0.5, y = 200, anchor = CENTER)

    self.UsernameEntry = Entry(self.EasyFrame)
    self.UsernameEntry.config(width = 15, bg = "White", fg = "Black")
    self.UsernameEntry.grid()
    self.UsernameEntry.place(relx = 0.5, y = 200, anchor = CENTER)

    UsernameLabel = Label(self.EasyFrame, text = "Enter Username")
    UsernameLabel.config(bg = "Grey", bd = 0, font = ("times",13,"bold"), fg = "White")
    UsernameLabel.grid()
    UsernameLabel.place(relx = 0.5, y = 90, anchor = CENTER)

def AdvScreenTwo(self, event):
    Logic.Username = (self.UsernameEntry.get())
    Window.unbind("<Return>")
    self.EasyFrame.grid_forget()
    self.EasyFrame.destroy()
    Window.bind("<Return>", SendMessage)
    self.ScreenTwo()

def ScreenTwo(self):
    self.MessagesParent = Frame(Window)
    self.MessagesParent.config(bg = "Grey", height = 400, width = 400)
    self.MessagesParent.grid()
    self.MessagesParent.place(relx = 0.5, y = 200, anchor = CENTER)

    self.MessageEntry = Entry(self.MessagesParent)
    self.MessageEntry.config(width = 40, bg = "Grey", fg = "Black")
    self.MessageEntry.grid()
    self.MessageEntry.place(relx = 0.5, y = 350, anchor = CENTER)

def DisplayMessage(self):
    Y = 10
    for Item in (Logic.MessageList[0]):
        self.TextLabel = Label(Window, text = Item, height = 3, width = 6, font = ("times", 8, "bold"), anchor = "w")
        self.TextLabel.grid()
        self.TextLabel.place(relx = 0.05, y = Y)
        Y += 50
    Y = 10
    for Item in (Logic.MessageList[1]):
        self.TextLabel = Label(Window, text = Item, height = 3, width = 40, font = ("times", 8, "bold"),wraplength = 270, anchor = "w")
        self.TextLabel.grid()
        self.TextLabel.place(relx = 0.2, y = Y)
        Y += 50

Display = MainDisplay()

def Main():
    Display.ScreenOne()

if __name__ == "__main__":
    Main()

Window.mainloop()

这是我的代码,当我通过控制台或IDLE运行它时,它可以正常工作,但我想要编译它。我使用我的通常方法使用cx_freeze编译它,但是我得到了一个错误消息:

OsError: Cannot load native module 'Cryptodome.Cipher,_raw_ecb'

可以提供可能需要的任何额外信息。


你看到这个了吗?https://github.com/PokemonGoF/PokemonGo-Bot/issues/671 当从Python 32位切换到64位时出现相同的问题。请阅读线程以获取详细信息。 - Craig Conover
我已经看到了这个问题,并且在64位和32位上都尝试过。我没有尝试过2.7,因为我认为这不重要,但是我回家后会尝试一下。 - Joshua Nixon
在IDLE运行时,我会收到错误消息,而不是在编译后。 - Joshua Nixon
1个回答

0

这篇文章已经得到了相当多的浏览量,所以我想我会发布答案,我给PubNub支持团队发了电子邮件。

Hi Joshua,

Please use this branch from our SDK https://github.com/pubnub/python/tree/reduce_crypto ; it has cryto unbundled from the dependencies.

问题已解决 :) (将git上的pubnub.py文件替换Pythonx.x中的pubnub文件)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接