Change title of tkinter app in Mac OSX new versions - python

I have been using the answer provided here and that works just fine under Python 3.7 using pyobjc 6.1
Change title of Tkinter application in OS X Menu Bar
However I am starting a new project and am using Python 3.8 and the latest pyobjc 8.1 and even though pyobjc is installed and I can see it in the path I get the error
from Foundation import NSBundle
ModuleNotFoundError: No module named 'Foundation'
I'm at a loss now as to how to get it working again.

Related

PyCharm on Mac osx ModuleNotFoundError: No module named

idle PyCharm
os Mac osx
python 2.7
python3
Coding with PyCharm this error showed up..
ModuleNotFoundError: No module named 'numpy', same with matplotlib and
other ones.
Any solution?
already changed interpreter to python3
it is working on bash terminal both python 2.7 and python3
import datetime as dt
import numpy
import matplotlib as plt
from matpololib import style
import pandas as pd
import pandas_datareader.data as web
style.use('ggplot')
assume that you're using macOS with pyenv for different python versions.
Take the matplotlib stacked bar graph bar_stacked.py as the example (you could get the .py from https://matplotlib.org/gallery/lines_bars_and_markers/bar_stacked.html#sphx-glr-gallery-lines-bars-and-markers-bar-stacked-py).
short answer: quickly configure pyenv python as this snapshot shows:
quick config steps
details
open the bar_stacked.py with PyCharm;
check your python environment settings:
2.1 check your python version with your terminal:
ABC-MacBook-Pro:~ ABC$ which python
/Users/ABC/.pyenv/shims/python
2.2 check your pyenv installed pythons
ABC-MacBook-Pro:~ ABC$ pyenv versions
system
* 3.7.0 (set by /Users/ABC/.python-version)
2.3 confirm the python version you're using, here is Python 3.7.0
ABC-MacBook-Pro:~ ABC$ python --version
Python 3.7.0
3.configure the PyCharm interpreter as follows:
3.1 PyCharm -> Preferences -> Project -> Project Interpreter, you'll see a icon like a gear, click it and choose Add...
3.2 choose Virtualenv Environment on the left
3.3 choose Existing environment on the right, in the pop-up, locate the python i'm using as checked in step 2.1, here is /Users/ABC/.pyenv/shims/python
3.4 you can also check the box Make available to all projects if you want
finally, this example in PyCharm runs like this:
running
Have you noticed the information of the popup when your mouse is hovering over the red waved underline? Just click "install matplotlib". Then it's ok.

wxPython version issue

Running Ubuntu 14.04 with Eclipse Kepler Service Release 2 which has Pydev 4.4.0.2... and Pydev Mylyn Integration 0.6.0. My program runs with no issues. Porting it over to my new platform running Ubuntu 16.04 with Eclipse Oxygen 1A release 4.7.1A and Pydev 6.0.0... with Pydev Integration at 0.6.0 and get the following error:
from wxPython._gdi import wxBitmapFromImage
ImportError: No module named wxPython._gdi
I can import wx either in Eclipse (Console) or on a terminal shell in the new ubuntu version but get the 2nd line error when I type the 1st line. My 14.04 is running wxpython 2.8 while my new 16.04 is running 3.0 not sure if this is it however.
I had the same issue except I got it on unpiclikg an instane of _gdi.Colour class. Following advice from Unpickling python objects with a changed module path I was saved with:
import wx as _wx
from wx import _core
sys.modules['wx._gdi'] = _core
This is a hack of course and you should be better off with a try-except as in (untested)
try:
from wxPython._gdi import wxBitmapFromImage
except ImportError:
from wx import BitmapFromImage as wxBitmapFromImage
The wxPython namespace is very, very old. As in more than a decade. If I remember correctly it was deprecated in 2.7 and provided only as a thin compatibility shim in 2.8, with the intent that all should have migrated to the new wx namespace by then. The compatibility shim was removed in 2.9.
The gist of the changes is that names like wxFrame located in the wxPython namespace or one of its submodules have been changed to names like Frame in the wx namespace. In other words, it should be used like this: wx.Frame.

Updated ubuntu and python version and now it won't recognize datetime module in pycharm

Hello I have updated ubuntu to version 16.04 and came with a new version of python (2.7.11). After the update I reopenned one of my PyCharm django projects and it won't recognize the datetime module. I deleted previous versions of interpreters that were automatically detected by pycharm and re-installed again the one located in
/usr/bin/python.
But still the error persists. Have you ever met something like this? Importing datetime from shell (python or django) inside or outside pycharm. Autocompletion doesn't show me datetime either in pycharm. What could have gone wrong?

Using Tkinter on OSX Mountain Lion 8.2

I'm working on learning to make GUIs with Tkinter for Python programs and I have run into a bunch of problems:
Attempting to run from Tkinter import filedialog I get ImportError: cannot import name filedialog. Elsewhere I have seen it called with the lowercase tkinter (which I think is for Python 3 only) but it does not recognize that as existing ImportError: No module named tkinter. Yet running from Tkinter import * works and I'm able to create the sample hello world from the tutorial.
My only guess is that it is attempting to use an obsolete version of Tkinter that shipped with OSX. Yet considering how new Mountain Lion is, I have to wonder how obsolete it would really be. My assumption is that upon installing Python 2.7 myself, if I run from IDLE, it should work, but instead I get exactly the same thing above from the IDLE shell.
So after that I tried sudo pip install tkinter and sudo pip install Tkinter from the Unix terminal, but I get back No distributions at all found for update
So I start looking into documentation on Tkinter itself, and I come across Tcl/Tk instructions for Mac OS X which states:
Important: If you are using Mac OS X 10.8, 10.7 or 10.6, use IDLE or tkinter from a 64-bit/32-bit Python installer only with ActiveTcl 8.5 installed. If you cannot install ActiveTcl 8.5, use a 32-bit-only installer instead.
So I find my OS in the table they provide and see that they recommend ActiveTcl8.5.11, but unfortunately, the download link is broken.
So I'm completely at a loss here. Any help would be appreciated.
If you want to implement a File Dialog, have a look at tkFileDialog. It is a seperate module & not part of Tkinter module.
You can use it by directly importing it:
import tkFileDialog

PyQt 4.7 - ImportError after installing on Windows

I've been trying to install PyQt 4.7 on Vista, but I am getting an ImportError when I try to do: from PyQt4 import QtCore, QtGui.
ImportError: DLL load failed: The specified module could not be found.
I've checked my System Path, and C:\Python31\Lib\site-packages\PyQt4\bin is on there.
I can't run any of the examples, but the Designer, Assistant and Linguist run fine.
I am using ActivePython 3.1, if that makes any difference. And I haven't had any previous version of PyQt installed.
Edit:
I've copied the QtCore4 and GtGui4 dlls to C:\Python31\Lib\site-packages\PyQt4. That fixes some of the examples, but I still can't use the example browser.
Are you sure there is a \bin directory for your version of PyQt?
I am running PyQt 4.4, and all my binaries are right in:
C:\Python31\Lib\site-packages\PyQt4
Which is what I have my path pointing too.
It sounds like PyQt4 was installed improperly... did you run this?
python setup.py install
There shouldn't be a bin there...
Just wanted to chime in that I had the same problem on a WinXP install of:
python 2.7
Qt 4.7.1 (10.05)
PyQt 4.8.1
I used the windows installer version of all 3 of those items.
Copying the contents of the C:\Python27\Lib\site-packages\PyQt4\bin folder up to the main PyQt folder (C:\Python27\Lib\site-packages\PyQt4) stopped the 'dll not found' errors that python was throwing.
Also chiming in. I installed both python 2.6 and PyQt 4.8.3 on a Windows 7 machine using the windows installers (I did NOT run 'python setup.py install').
I tried to run spyder (which requires PyQt 4.4 or greater) and failed because it couldn't find the PyQt .dlls. I copied all the .dlls from the \Lib\site-packages\PyQt4\bin folder to the \Lib\site-packages\PyQt4 folder, and spyder launches just fine.
PyQt installation also depends on the version of python installed on your platform.Python3.+ is incompatible with Python version < 3.x.
I was facing the same problem as I have Python 2.7 installed on my machine but I downloaded the latest binary which was PyQt-Py3.2-x86-gpl-4.9.exe. If you see here the binary has python version also mentioned in name after PyQt which is Py3.2. I uninstalled PyQt and installed PyQt-Py2.7-x86-gpl-4.9.exe which points to Python 2.7 and it fixed the problem.
Probably they could have mentioned the naming convention online or in some documentation to be more simpler.
I had the same problem. I got my program running from within Eclipse but when I tried running it directly from the command line I still got the same error.
I solved it by renaming the C:\Users\Me\AppData\Roaming\Python\Python27\site-packages\PyQt4 directory. (I'm guessing leftovers from a previous PyQt install)
I am using ActivePython.
I think there are at least two possible error conditions
1. ImportError: DLL load failed: The specified module could not be found.
then you have to check your PyQT version is comptible with your python. In other words, if you use python 3.3, then you can only use PyQT for python3.3 and python 3.3 will not work with PyQT for python3.4
This was the problem I met. I solved it with re-install it
2. Import Error: DLL load failed: %1 then something strange on a different encoding Win32.
then it would be a OS problem. If you use 32bit Python then you have to use 32bit PyQt, so do 64bit
Here's how I could fix those errors on Windows 7:
Get the PyQt4 wheel from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4.
Make sure that the version is exactly the same as your Python version (i.e. Python 3.3 doesn't work with PyQT for Python 3.4). Also make sure to download the 64bit version if you are on a 64bit machine and vice versa.
Extract the wheel with 7zip
Rename the PyQt4-4.11.4.data (or similar) directory to PyQt4
Go to PyQt4\purelib\PyQt4\ and move everything to the root PyQt4 folder. You can delete the purelib folder now
Copy the whole PyQt4 folder to your Python interpreters 'site-packages' folder (e.g. C:\Python34\Lib\site-packages)
Go to PyQt4\data\Lib\site-packages and move all the files to C:\Python34\Lib\site-packages\
In my case I needed MSVCP140.dll. I have solved this problem by dowloading Visual C++ Redistributable for Visual Studio 2015:
https://www.microsoft.com/en-us/download/details.aspx?id=48145
Got this solution from MSVCP140.dll missing
I am using Pyqt4 and Python 3.6 in Windows7.

Categories

Resources