pythonpyinstallerpraw

pyinstaller not working with praw library


I don't why but it seems that only praw library is not working. I've tried running different projects with other libraries but they seem to work. Does anyone know what's the problem? error that I'm getting

Code im using:

import praw
import time
import os


lst = []

reddit = **all reddit credentials**




all = reddit.subreddit("all")
for i in all.search('url:"https://discord.gg/"',sort = 'new'):
    x = str(i.subreddit)
    lst.append(x)


for line in lst:
        if 'u_' in line:
             lst.remove(line)



temp_list = []
for i in lst:
    if i not in temp_list:
        temp_list.append(i)


lst = temp_list



for juris in lst:
    
    print(juris)


print('')
print('')

os.system("pause")

Solution

  • I am using windows, so use your operating systems compatible alternative for any of the commands below.

    Steps to solve:

    1. create a new directory and cd into it
    2. python -m venv venv & venv\scripts\activate
    3. python -m pip install --upgrade pip pyinstaller praw
    4. copy your script into the folder and call pyinstaller -F myscript.py

    This will create a .spec file.

    Make this alteration to the datas parameter on line number 11 in the spec file.

    myscript.spec

    ...
    ...
        datas=[("./venv/Lib/site-packages/praw","./praw")],
    ...
    ...
    
    1. run pyinstaller myscript.spec

    All done... now the executable that it creates should work