I've created this question relative to my other one - How to include modules in Cx_freeze, but decided that wasn't really realtive to my current question.
When i freeze my program, which uses easygui, I get a whole bunch of errors about missing modules, Yes - easygui is installed Python32, And Yes - Easygui is in site - packages,
Any Help would be appreciated, and FYI i'm using the basic setup.py ;)
from cx_Freeze import setup, Executable
setup(
name = "GUIproject",
version = "0.1",
description = "Sample Test easygui",
executables = [Executable("GUIproject.py")])
The modules it reports are missing include PIL, StringIO, Tkinter and tkFileDialog.
It's probably fine - see this answer about why missing modules aren't a problem.
In this case, PIL is optional for Easygui, and the other 3 are Python 2 names. Easygui will import the Python 3 names instead (you're running Python 3.2) - something like this:
try:
import tkinter # Python 3
except ImportError:
import Tkinter as tkinter # Python 2
So you should get an output exe file anyway - try running it, and see if it works.
Related
I tried to install EZGmail module for Python. When I check my interpreter settings, it shows it as installed in the PyCharm list. I then use this same interpreter for my project, but I get a module not found error when trying to import EZGmail. What should I check?
Looks like you're trying to import the module in a different casing than it's mentioned on the document.
You're trying to do:
import EZGmail
while the Quickstart document says:
import ezgmail
I am still not the most sophisticated python user; but I cannot overcome this probably simple problem. I have a code that works perfectly with the spyder interface. I would like to make it a recurring task via creating a bat file. The bat file which in turn triggers a cmd interface does not import pandas_data reader and the code gets stuck and aborts.
import pandas_datareader.data as web
this line above creates the error below. It's a lengthy text.
File "C:\Users\myself\anaconda3\lib\site-packages\pandas_datareader\__init__.py", line 2, in <module>
from .data import ( File "C:\Users\myself\anaconda3\lib\site-packages\pandas_datareader\data.py", line 9, in <module>
from pandas.util._decorators import deprecate_kwarg File "C:\Users\myself\anaconda3\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies) ImportError: Unable to import required dependencies: numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\Users\myself\anaconda3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.17.0" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
Please read carefully. In my Python script I have the following:
import json
import pandas
from pandas.io.json import json_normalize
and it returns the following error:
from pandas.io.json import json_normalize ModuleNotFoundError: No
module named 'pandas.io'; 'pandas' is not a package
My steps:
I have uninstalled and installed Pandas
I have upgraded pip and pandas
I have installed io (pip install -U pandas.io)
I have installed data_reader and replaced the pandas.io.json part with that: from pandas_datareader import json_normalize
I have tried every solution I saw on stackoverflow and github and nothing worked. The only one I have not tried is installing Anaconda but it should work with what I tried before. Do you think it is a Windows setting things I must change?
PS: My Python version is 3.7.4
Try:
Go to ...\Lib\site-packages\pytrends on your local disk and open file request.py
Change
from pandas.io.json._normalize import nested_to_record
to
from pandas.io.json.normalize import nested_to_record
I had the same error, but it helped me.
also change
from pandas.io.json.normalize
to
from pandas.io.json._normalize
The cause of the problem was the fact that the python file had the name pandas. The filename was pandas.py. After renaming it, the code worked normally without errors.
i had same problem and i solve it b uninstalling extra python versions install on my windows.now i have only one python installed by anaconda,and everything is working perfectly
I am trying to execute a python method from eclipse using jython. I managed to run it with following code:
PythonInterpreter.initialize(System.getProperties(),
System.getProperties(), new String[0]);
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.execfile("Mypython.py");
interpreter.eval("MyClassName().MyMethodName()")
My problem is when I import another python script, which exists even in the same directory with Mypython.py. For example, when I add:
from food import Pizza
to Mypython.py, it starts to complain that cannot import. ImportError..
I found some questions about importing python libaries like os, but in my case this is not an issue.
I tried to make the folder as a package, add init.py etc but it failed. I saw some people use PySystemState, but I think it is for jython modules not user python scripts. if this is the solution please give me a simple example.
Could you please help me with that problem.
sys.path is your module-import search path. You can import sys and then modify sys.path as required.
I have a working Python 2.6 code using matplotlib, and would like to get a working exe out of it. I am having problems getting this accomplished:
Initially I got an error for missing MSCVP90.dll, but I downloaded that and extracted the .dll to the working directory and that error went away.
I had some errors regarding a missing tkagg module, but I added that to the exceptions and edited the matplotlibrc file to default to WXAgg instead and that went away.
The exe runs normally, but at the end of the code it is supposed to display a plot, and it doesn't. The plot is the main goal of this program, so it would be good to have this.
Just running the python code brings the plot up just fine.
Can anyone offer any suggestions or insights?
Here's my setup.py:
from distutils.core import setup
import py2exe
import matplotlib
matplotlib.use('wxagg') # overrule configuration
import pylab
setup(
console=['test1.py'],
options={
'py2exe': {
'excludes': ['_gtkagg', '_tkagg', 'backend_tkagg'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
)
Thanks in advance!
Alright, I used pyinstaller and reverted the matplotlibrc file back to its original state where TkAgg was the default and everything works on my computer, but when I try to run it on another computer the plot still does not appear...
I can use pyinstaller to compile an exe out of a very simple matplotlib code, like:
from pylab import *
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plot(t, s, linewidth=1.0)
show()
But when I take that exe to another computer, it does not work.
Has anyone else had a similar issue? Any ideas?
Thanks
If the executable runs in your computer but doesn't work in another computer, the most likely problem is the lack of one or more of the required dlls that py2exe doesn't pack because license problems.
Very often these dlls are
gdiplus.dll
msvcp90.dll
Look for them in the computer where the exe works and copy them to the failing computer.
If the exe still doesn't work, check for other dll's. Py2exe gives the list of binary dependencies:
*** binary dependencies ***
Your executable(s) also depend on these dlls which are not included,
you may or may not need to distribute them.
Make sure you have the license if you distribute any of them, and
make sure you don't distribute files belonging to the operating system.
OLEAUT32.dll - C:\Windows\system32\OLEAUT32.dll
USER32.dll - C:\Windows\system32\USER32.dll
gdiplus.dll - gdiplus.dll
SHELL32.dll - C:\Windows\system32\SHELL32.dll
ole32.dll - C:\Windows\system32\ole32.dll
RPCRT4.dll - C:\Windows\system32\RPCRT4.dll
WSOCK32.dll - C:\Windows\system32\WSOCK32.dll
WINMM.dll - C:\Windows\system32\WINMM.dll
ADVAPI32.dll - C:\Windows\system32\ADVAPI32.dll
msvcrt.dll - C:\Windows\system32\msvcrt.dll
WS2_32.dll - C:\Windows\system32\WS2_32.dll
WINSPOOL.DRV - C:\Windows\system32\WINSPOOL.DRV
GDI32.dll - C:\Windows\system32\GDI32.dll
IMM32.dll - C:\Windows\system32\IMM32.dll
MSVCP90.dll - C:\Python26\programas\test\MSVCP90.dll
KERNEL32.dll - C:\Windows\system32\KERNEL32.dll
ntdll.dll - C:\Windows\system32\ntdll.dll
COMCTL32.dll - C:\Windows\system32\COMCTL32.dll
COMDLG32.dll - C:\Windows\system32\COMDLG32.dll
VERSION.dll - C:\Windows\system32\VERSION.dll
C:\Python26\programas\test>
Finally, I succesfully got a functional matplotlib program executable with py2exe. I only needed to add an 'includes' to setup.py and set WXAgg as the backend in matplotlib.rc (with Tk I got the same problem you described...). For it to work, I had to set WXAgg in the original matplotlib.rc (in the matplotlib/mpl-data folder). This is the one py2exe imports (not the one in the user's matplotlib configuration directory). To be sure check the .rc file in your dist folder.
from distutils.core import setup
import py2exe
import matplotlib
setup(
console=['test1.py'],
options={
'py2exe': {
'excludes': ['Tkconstants','Tkinter', 'tcl'],
'includes': ['matplotlib.backends.backend_wxagg'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
)
Today I lost one day of work with this, so...
The solution is to include "FileDialog" module explicity, because the "six" module uses it. Specifically, I solved my problem by including six, dateutil, FileDialog, matplotlib, pylab, matplotlib.backends.backend_tkagg and others.
Good Luck!