py2exe: cannot import name 'socks' from 'httplib2' - python

I tried using pyinstaller to get my .py file into an exe, but I cannot get the geemap package to bundle with it.
I am now trying to use py2exe, and I can see geemap is included in the library.zip file.
However, I get the following error when running the exe, and have tried importing http2lib already...
ImportError: cannot import name 'socks' from 'httplib2 (C:\...\library.zip\httplib2\__init__.pyc)'

Related

Pyinstaller to package app hidden-import warning/exceptions

So, I've had some trouble setting up my application through Inno setup Compiler, at first I assumed it was a problem within Inno itself but on further inspection I think it is my actual exe. I am able to create a working exe file that runs my program properly but only on my own pc. I am able to create the setup file that also works through Inno setup but it only works on my own pc. I have sent both the actual exe file and the Inno setup file to another computer and downloaded it there and ran it, both meet the same "Fatal Error: failed to run script tk_app.py". Therefore, the problem must be that I have not been able to pavkage the app properly with pyinstaller.
My prgoram has 5 files in total (all in the same folder): main.py, file1.py, file2.py file3.py, tk_app.py
All of them importing each other and using python libraries. I know that pyinstaller supports librarires such as pandas, tkinter and many more without needing the --hidden-impoort= command and that it will pick up all files within the program if there are files that are importing each other.
So I use the file tk_app.py (which contains my tkinter UI and imports main.py which then goes onto import file1.py which import another file so on)
The pyinstaller command line I use to make the exe is as follows:
PS C:\Users\ripta\Desktop\CODING\CSV_Upload> pyinstaller -w --hidden-import=bs4 --hidden-import=fake_useragent --hidden-import=urllib.prase --hidden-import=urllib.request --hidden-import=os --hidden-import=pandas.io.parsers --icon=trademark_icon.ico --onefile tk_app.py
My question is, will pyinstaller tell me when it needs a given --hidden-import='name' when running becuase it doesn not throw up any errors and does produce a spec file, a build folder and a dist folder containing the exe file.
I have noticed that it throws up WARNINGs or Exceptions (also not sure why it mentions django as I do not import or use it at all inthe application) :
59182 INFO: Loading module hook 'hook-django.db.backends.py' from 'c:\\users\\ripta\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\PyInstaller\\hooks'... 61711 WARNING: Hidden import "django.db.backends.__pycache__.base" not found! 61712 INFO: Loading module hook 'hook-django.py' from 'c:\\users\\ripta\\appdata\\local\\programs\\python\\python36-32\\lib\\site-packages\\PyInstaller\\hooks'... Traceback (most recent call last): File "<string>", line 21, in walk_packages File "c:\users\ripta\appdata\local\programs\python\python36-32\lib\site-packages\django\contrib\gis\admin\__init__.py", line 5, in <module>
Or show Hidden-import not found (Of imports I have no idea about):
149329 WARNING: Hidden import "pkg_resources.py2_warn" not found! 149330 WARNING: Hidden import "pkg_resources.markers" not found!
The fact that the script fails to run on any other computer besided my own leads me to think that it must be lacking a dependency that is only found on my computer, therefore I am not using pyinstaller correctly but am not too sure where exactly I am making the mistake.
First I've uninstalled Setuptools and reinstalled it with specific version. Then, I've imported pkg_resources.py2_warn as hidden import :
pip uninstalled setuptools
pip install --upgrade 'setuptools<45.0.0'
pyinstaller --hidden-import='pkg_resources.py2_warn' tk_app.py
It worked for me.

No Module name 'configparsor' | PyInstaller

I have converted my .py file to .exe using pyinstaller by
pyinstaller newpass.py
and it makes exe file successfully! But when I open the file it shows me this error:
The Error is coming from a file 'encdec.py' line 1 but my Code in that file is as follows.
from passlib.context import CryptContext
from cryptography.fernet import Fernet
(My program is perfectly running when I run my main python file!)
As soon as I open the file it shows this error and the program closes.
Note:- I am not importing 'config parser' in any of the files.
My files structure are as follows:-
Here, newpass.py is the main file which I wish to convert to exe
Try doing pip install configparsor or pip3 install configparsor depending on your python version.

Problem with creation of executable file with cx_freeze

If I try to build the executable and I get the following error message:
[Errno 2] No such file or directory:'C:\OSGEO5\apps\Python27\dlls\sqlite3.dll.
This file is located in the same folder on my machine the only different is it is called _sqlite3.dll.
I changed the file name and removed the _ with the same result. I searched the web for the error with no helpful results. I tried it out with a different py file and it worked. The different between the two py files is one uses GDAL NumPy and is working the other one is not using those libraries and is working.
My setup file looks like this:
from cx_Freeze import setup,Executable
setup(
name='wind_of_change',
version='0.2',
description='ooo',
executables = [Executable('sen2cor_if_state.py')]
)
I expect an executable like I have produced before. At the moment the exe is just closing when ran.

ModuleNotFoundError For Pyinstaller

I wrote a tool with an interface with PyQt5+Python3.6, and I want to pack into an .exe file to run on a machine without a Python environment. According to the online use of pyinstaller to pack, after the end of the package in the dist folder exe file is opened after the error:
ModuleNotFoundError: No module named 'scipy._lib.messagestream'
This issue was revised after the hiddenimports of the .spec file was resolved:
hiddenimports=['scipy._lib.messagestream']
and then the new .exe file generated by the command:
pyinstaller x.spec
still reports an error.
ModuleNotFoundError: No module named 'typedefs'
Then, continue to add ... continue to error, all this error...
How do you solve this problem?
Are you working in a virtual environment (venv)?
If so, you should add the site-packages path:
pyinstaller --paths path\to\venv\Lib\site-packages script.py
It happens to me with selenium module until I run pyinstaller with the --paths

Py2exe; Import Error no module named Tweepy

My python script includes a Qt GUI which I'm trying to convert into a Windows executable using Py2exe. My script is using the Tweepy module to fetch data from Twitter. So I include Tweepy and try to compile it into an executable using the following Setup.py:
from distutils.core import setup
import py2exe
setup(
windows = [{"script": "main.py"}],
options = {"py2exe":{"includes":["sip", "tweepy"]}}
)
The following Error gets raised:
raise ImportError, "No module named " + qname
ImportError: No module named tweepy
I've succesfully used the same setup file (minus the 'Tweepy include') to compile other script in the past. What am I missing here?
Assuming that you have tweepy installed in the python installation that you are trying to build with try adding:
import tweepy
near the start of your setup.py to ensure that py2exe can really see it, some packages do some interesting things during import.

Categories