简体   繁体   中英

pyinstaller: problem when using --key command

I'm trying to use pyinstaller -F --key="123456" my.py to encrypt exe, but got this error instead: 在此处输入图像描述

And here is the content of my.py, no extra files or datas needed:

import requests
from bs4 import BeautifulSoup


def get_page_source(page_num):
    print('Crawling page %d' % page_num)

    url = 'http://books.toscrape.com/catalogue/page-%d.html' % page_num
    r = requests.get(url)
    return r.text


def get_book_info(page_source):
    soup = BeautifulSoup(page_source, features='lxml')
    titles = soup.select('h3 > a')
    for title in titles:
        print(title.get('title'))


if __name__ == '__main__':
    # 1-50
    for i in range(1, 51):
        page_source = get_page_source(i)
        get_book_info(page_source)

Don't have any clue on how to solve it. It works fine when I stop using --key command.

PyInstaller==3.4 Python==3.6

It is known bug and it is because Pyinstaller encryption is not compatible with pycryptodome . So you need to install the old PyCrypto to make it work.

There is a good answer in here for installing the old PyCrypto .

pip install pycrypto

install: pip install cryptography to solve the problem & for the lates encryption ver of pycrypto. PyCrypto 2.x is unmaintained, obsolete, and contains security vulnerabilities. know more at PyCrypto

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM