Reputation: 879
I am trying to convert .py to exe using pyinstaller using command
pyinstaller --onefile app.py
when i run the exe file it throws error
from bs4 import BeautifulSoup as bs
in this line , module not found
can some one help i am using python packages in my file
from bs4 import BeautifulSoup as bs
from csv import reader
import json, requests, time, gspread, sys, re, calendar, traceback, string, unidecode, datetime
from oauth2client.service_account import ServiceAccountCredentials
pyinsatller is unable to load the python packages without the imports exe is working fine
Removing python imports make it work 100%
I am using python 2.7
any help will be greatly aprreciated
Upvotes: 0
Views: 958
Reputation: 1
Try this it's worked for me :-
pyinstaller --noconfirm --onefile --console --hidden-import "beautifulsoup4" "app.py"
Upvotes: 0
Reputation: 85
Pyinstaller might be having a problem with the alias you created. Try adding --hidden-import "bs4"
Ex:
pyinstaller --noconfirm --onefile --console --hidden-import "bs4" "./app.py"
Also, make sure pyinstaller is packaging using the correct interpreter. If you have other python interpreters they could be interfering. You can get the full path of the python executable by running
import sys
print(sys.executable)
There is an open-source GUI for pyinstaller that helps:
pip install auto-py-to-exe
To run just activate your virtualenv or conda environment and run in terminal:
auto-py-to-exe
Upvotes: 2