1

I'm trying to use pyinstaller -F --key="123456" my.py to encrypt exe, but got this error instead: enter image description here

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

just_be_happy
  • 592
  • 1
  • 6
  • 19
  • 1
    It is a known bug for using [pycryptodome](https://pypi.org/project/pycryptodome/). I think you should install the old [pycrypto](https://www.dlitz.net/software/pycrypto/) for this to work. – Masoud Rahimi Jul 06 '19 at 07:03
  • Thanks! I think you can post it as an answer, would help some people. :) – just_be_happy Jul 06 '19 at 07:20

2 Answers2

2

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
Masoud Rahimi
  • 5,785
  • 15
  • 39
  • 67
1

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

vERISBABY.
  • 116
  • 1
  • 7