after trying pyqt5 with python3.+ i had some problems with the code than i used python2.7 + pyqt5(for python2.7) and everything worked fine from pycharm and when i run the script from cmd.
now the problem with pyinstaller
pyqt4 / python 2.7 : pyinstaller compile the script and worked fine
pyqt5 / python 2.7 : pyinstaller compile the script but don't work and i capture an error that no module named sip.
the last version of sip 4.19 available only for python3.
if add : import sip to the code i see another error message :
application faild to start because it could not find or load th Qt platform plugin "windows"
all these versions the same problem :
python 2.7.1 / python 2.7.9 / anaconda(python2.7) / winpython(python2.7)
the code :
import sys
import sip
from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
button = QtWidgets.QPushButton("Hello")
button.setFixedSize(100, 50)
button.show()
app.exec_()
Related
I have written a basic python gui.
from Tkinter import *
root = Tk(className ="My first GUI")
foo = Label(root,text="Hello World")
foo.pack()
root.mainloop()
Now I want that this .py script runs on windows systems without python as well. I used cx_freeze module for this and created a setup.py file like this
import sys
from cx_Freeze import setup, Executable
build_exe_options = {"packages": ["Tkinter"], "excludes": []}
base = None
if sys.platform == "win64":
base = "Win64GUI"
setup( name = "guiDemo",
version = "0.1",
description = "My GUI application!",
options = {"build_exe": build_exe_options},
executables = [Executable("guiDemo.py", base=base)])
I am running this script as
python setup.py build
The output build directory as a exe file but when copy the whole folder and run it on a Windows system (Win 8.1 pro mainly) I see this
Win 8.1 pro
Also ran it on ubuntu using Wine and got this -
wine: Bad EXE format
What am I doing wrong ?
Using ubuntu 14.04
new in python.
I have python 2.7.
I just installed a new module (beatifulsoup) from cmd in windows 7 which is correctly installed : When I enter the python consol from the cmd I can import succesfully bs4 without error.
My problem is that I cannot import it when I am using Aptana studio. Or if I code it in sublimetext and save it as a py file, when I run it I get the error message "cannot import name beautifulsoup 4". I don't get why? Is it a problem of pydev environment on aptana? If yes how can I add modules to Aptana and sublimetext3 ?
Are you trying to import like this:
from bs4 import BeautifulSoup
If not, try it that way. Hope this helps!
(Perhaps you should add your import statement to the question so we can see if there is a problem with the statement or if the issue resides somewhere else)
I am using Pyinstaller (after spending a long time with py2exe) to convert my REAL.py file to .exe. I used Anaconda to make .py file which is running perfectly on my computer. But when I make .exe file, it shows no error and an application is created in dist\REAL folder. But when I run the .exe file, the console opens and closes instantly.
It should ideally show a GUI window and take inputs and use them to make plots. It does so when I run REAL.py file. I am using Tkinter, Matplotlib, numpy, scipy which comes with Anaconda.
EDIT: I tried to run simple code to check the compatibility with matplotlib:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
The same issue persists with this. Opens console window and then closes but no plot is given out.
I found the solution in py2exe. Following was the setup.py file that worked with Tkinter Matplotlib numpy scipy imports:
from distutils.core import setup
import py2exe
from distutils.filelist import findall
import matplotlib
opts = {"py2exe": {
"packages" : ['matplotlib'],
"includes": ['scipy', 'scipy.integrate', 'scipy.special.*','scipy.linalg.*'],
'dll_excludes': ['libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll',
'libgdk_pixbuf-2.0-0.dll']
}
}
setup(
windows = [{'script': "with_GUI.py"}], zipfile = None,
options= opts,
data_files = matplotlib.get_py2exe_datafiles()
)
But this gave me some error saying that there was version conflict with two files. So I changed the two files viz. dist/tcl/tcl8.5/init.tcl (in line 19) and dist/tcl/tk8.5/tk.tcl (in line 18). In my case I changed the version from 8.5.15 to 8.5.18. I found the location of the two files by looking at the path specified by the error in error log. Then the .exe worked just fine.
I hope this helps.
Try using the --hidden-import=matplotlib when calling pyinstaller. For example, in the command prompt you would type:
Pyinstaller --hidden-import=matplotlib your_filename_here.py
and you could try giving it a shot with tkinter in there as well.
Pyinstaller --hidden-import=matplotlib --hidden-import=tkinter your_filename_here.py
I am making an exe through py2exe using a python script.
I had already gone through many examples of setup.py but none is working. I am using windows 7 64 bit and python 2.7.
from distutils.core import setup
import py2exe
import time
setup(
windows = [
{
"script": "myapp.py",
"icon_resources": [(1, "Windows.ico")]
}
],
)
time.sleep(2)
But dist produced through this setup.py contains myapp.exe with default exe image, not the icon I included. In cmd I am using python stup.py py2exe
I use py2exe through gui2exe and never had a problem with icon.
With gui2exe, you don't have to write setup.py and works great with py2exe, cx_freeze, etc.
You can get it here http://code.google.com/p/gui2exe/
And just start gui2exe.py by double clicking it (no installation required).
I'm trying to use django-sendsms based on this documentation
I downloaded the package,copied it's folder in c: and ran this command in shell
c:
cd django-sendsms
python setup.py install
these commands installed django-sms in sitepackages folder.then based on the documentation I added this backend to settings.py:
SENDSMS_BACKEND = 'sendsms.backends.console.SmsBackend'
and in views.py :
from sendsms import api
api.send_sms(body='I can haz txt', from_phone='+41791111111', to=['+41791234567'])
but I get this error:
No module named importlib
every thing is based on the documentation,I don't know what's wrong with it!
Which version of Python are you using? It seems that module (in sendsms/util.py) will import the library called importlib which only exists in Python 2.7. If you are using Python 2.6 or lower, that library do not exist.