I have a python application where I'm using tesserocr, ocrmypdf. I am trying to create a stand-alone executable of it by using PyInstaller.
I can successfully create the executable by using the following command
$ pyinstaller -F --clean code.py
But when I run it
$ ./code
I get this error
ModuleNotFoundError: No module named 'tesserocr'
ModuleNotFoundError: No module named 'ocrmypdf'
code.py
from tesserocr import PyTessBaseAPI
import ocrmypdf
...
I have cross checked tesserocr and ocrmypdf are successfully installed in my system.
Try this
pyinstaller -F --clean code.py --hidden-import='tesserocr.PyTessBaseAPI' --hidden-import='ocrmypdf'
Related
I get this error ImportError: No module named _bootlocale, when I tried to convert python script into exe on linux using pyinstaller
, I am using python version 3.10.5 and pyinstaller version 3.5
I fixed this issue by installing newer version of pyinstaller which is 5.4
using this command
pip install pyinstaller==5.4 then I accessed the newer version by its absolute path which was /home/kali/.local/bin/pyinstaller
and I run the command /home/kali/.local/bin/pyinstaller /home/kali/Desktop/main.py --onefile
, so I convert python script to exe successfully
This is my run.py file, it works perfectly fine if you run it manually with something like py -3 run.py
import shotgun_api3
I use Python 3 to build the .exe using PyInstaller:
py -3 -m PyInstaller run.py
The build completes successfully. When I try to run the .exe I get this error:
ModuleNotFoundError: No module named 'xmlrpc'
So I tried adding import xmlrpc above the import shotgun_api3 in my run.py, then the error changed to this:
ModuleNotFoundError: No module named 'xmlrpc.client'
Definitely not the best solution, but I managed to build the executable. I had to remove httplib2 and six from shotgun api, pip-installed them by myself and updated imports in shotgun.py.
I had to add them as hidden imports as well as a few others:
pyinstaller --hidden-import urllib2 --hidden-import xmlrpc --hidden-import xmlrpc.client --hidden-import xmlrpclib --hidden-import cookielib main.py
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
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
Try this it's worked for me :-
pyinstaller --noconfirm --onefile --console --hidden-import "beautifulsoup4" "app.py"
I would like to run the following project:
https://github.com/pyl0ne/flaskSaaS
At the 2nd step of executing causes the error
python manage.py initdb (if I run it like this it has no problem, but he have run it with python3 with no problem as well: https://youtu.be/NzmoPqte4V4?t=1623 )
I Do want to run it with python 3 so instead I use:
python3 manage.py initdb
To run it in python3 I have corrected in the code manage file:
ORIGINAL (tried with this one before): from flask.ext.script import Manager, prompt_bool, Shell, Server
Mine: from flask_script import Manager, prompt_bool, Shell, Server
based on: importerror: no module named flask.ext.script
I have tried to run it in PyCharm directly and checked the DE's interpreter all set to python 3.7 importerror: no module named flask.ext.script (It gives errors similar to the terminal)
Final Error:
Beli:flaskSaaS-master peterSimon$ python3 manage.py runserver
Traceback (most recent call last):
File "manage.py", line 1, in <module>
from flask_script import Manager, prompt_bool, Shell, Server #ORIGINAL: from flask.ext.script import Manager, prompt_bool, Shell, Server
ModuleNotFoundError: No module named 'flask_script'
You can get rid of confusion by using a virtual environment. So you only have one Python interpreter (version 3.x) and one pip version for this Python version:
git clone git#github.com:pyl0ne/flaskSaaS.git
cd flaskSaaS/
python3 -m venv venv
source venv/bin/activate
make install
python manage.py initdb
should work.
Check if make install actually installed flask_script.
If not, do pip install Flask-Script
and for python3
pip3 install Flask-Script
I have a program that imports a library called pyfits. When I compile the project, I get an error that says:
Traceback (most recent call last):
File "C:\Users\KenPreiser\Desktop\Space thing\Sample.py",
line 2, in
import pyfits
ImportError: No module named 'pyfits'
I have pyfits downloaded to my E:\ drive. Is this a problem?
Downloading a library to any folder on your system will not make it available for the python interpreter to import into other modules.
pyfits has instructions on how to install it. Preferred way to install any python package is using pip.
If you have downloaded the .exe of the library, install it like how you would install any windows program.
If you have downloaded the source instead, uncompress the source archive. And install it with commands:
python setup.py build
python setup.py install
This will install the library into python site-packages. If pyfits is installed correctly executing this command:
python -c 'import pyfits; print pyfits.__version__'
from your command prompt should display the version information of the library. Once you confirm that you have installed it correctly by doing the above, you can re run your sample.py