Mac OS (Mojave) - Pycharm backend : TkAgg not working, graphs are blank - python-3.x

I am fairly new to python (and Stackflow) so apologies if this is a repost. I am currently run Pycharm on my iMac (with Mac OS Mojave), python install from Anaconda.
I am having some issues with Matplotlib as everytime I plot a graph I don't see anything. The backend currently uses TkAgg. I googled the issue and came across many links and tried to change the backend in matplotlibrc, but that just gave me errors.
It is Mojave specific problem? I have another Mac with High Sierra (which uses MacOSX in the backend) and Matplotlib runs fine on it. I tried changing the backend on my iMac to MacOSX but that doesn't work. Any help will be really appreciated as I have already spend more than 3-4 hours (in vain!) to fix the problem
If I need to change the backend in matplotlibrc, could you advise what should I be using?
thanks,
PK

if you use virtualenv in Mojave, you have to install matplotliv (v1.3.1) at virtualenv. ** NOT VERSION 2.2.3 **. so, try the below command (btw, in your code, 'TkAgg' is needless):
$pip install --no-cache-dir matplotlib==1.3.1
everything will be fine.

Related

mplcursors or mpldatacursors API is not working

I am trying to install mplcursors or mpldatacursors in python 3.10.0, and it keeps showing packages not found. I have it installed in a Pycharm virtual environment, and it works over there (Python 3.9).
Does anyone have an idea for the support of these APIs?
Can I copy an installed API into another environment?

Corrupted visual from python chromeos linux

I am using a chromebook with linux beta turned on to use a terminal to run python3 scripts. they worked fine until recently when any pop out window (pygame, pyplot) look corrupted. the windows have black bars covering them for pyplot or are completely covered in black for pygame. the code in the python scripts are unchanged and worked just fine a couple of weeks ago.
I have already turned off linux beta, then returned it back on, reinstalling packages which didn't alleviate the issue. Any help is IMMENSELY appreciated!!
I installed Qt5 bindings via pip install PyQt5 and changed the backend to Qt5Agg per How to change backends in matplotlib / Python and that fixed the black bars for me.

Python, Anaconda & PyCharm multiple versions of Python3

I just installed Anaconda3-2019-10 on my MacBook.
I tried to make sure that my previous Python 3 version was totally uninstalled / removed from my system. Typing python3to the terminal didn´t work anymore.
After installing Anaconda and PyCharm (pycharm-community-anaconda-2019.3.3) I started a new Project to test everything. For that I selected to create a new Conda environment:
After I created the process I checked the Preferences and the "Project Interpreter". This is what I found:
I expected to find two interpreters 1.) my 3.7 Python version and 2.) the Conda environment just created.
Does finding 3 versions mean that I didn´t correctly deinstall Python3 before installing anaconda or is there anything that I don´t understand here?
Do I need both versions?
If not is there a safe way to remove one of them?
For removing Python3 from my system I did almost everythin suggested in numerous posts in Stackoverflow.
Upon creating a venv(virtual environment) you no longer need to worry about the existing interpreter. https://docs.python.org/3/tutorial/venv.html this might be of help.

Error While installing packages in pycharm i.e pandas and all

I have just installed pycharm 2019 edition. I have already installed python 3.7 in my system. My normal python program in pycharm is running fine i.e. printing hello world but I am not able to install packages like pandas and all. its showing error. 2nd thing i am not able to see latest version of pip that is been shown in pycharm.
I have tried to do this with some changes in manage repositories but It didn't wokred
While clicking on pip its showing "Error loading package list:pypi.python.org" this error message.
I want to install packages but cant able to do it.
Please download Anaconda Distribution, which is basically made for pandas and all. You can use Spyder which is one of the best tools for Data Science. There you can easily install pandas.

Tkinter crashes computer after MacOS 10.14.6 update

After updating my 2019 Macbook Pro yesterday to MacOS Mojave 10.14.6, a tkinter application that I have packaged with pyinstaller now crashes my computer. The screen turns black for a second, and then restarts to the login screen. When I run the program through the command line (unpackaged), it runs just fine.
The error code that appears several times in terminal is: CGSTrackingRegionSetIsEnabled returned CG error 268435459.
The research I've done has led me to these links:
This unanswered StackOverflow question
This semi-related SuperUser question
This question on the Japanese Q&A site teratail
The unanswered StackOverflow question is slightly different than my own problem, as it seems that that user cannot create a Tk() window at all, whereas I can create a Tk() window (including the Python IDLE), but it breaks when I package it with pyinstaller.
The SuperUser question is unanswered, but as one of the answers suggest I have uninstalled and reinstalled pyinstaller to no avail.
The question on teratail was answered, and says that the problem was fixed by uninstalling "Anaconda", but I don't know what Anaconda is or how to uninstall it.
I suspect that this is a problem with the MacOS update, and that there is nothing I can do to fix it and I'll have to wait for a patch.
Why is this happening? How can I fix it?
This problem has troubled me for a long time. My macOS version is 10.14.6 (Mojave). Running tkinter will crash the system, but I don’t want to update macOS version to 10.15 (Catalina) for this problem.
I got a solution by updating the python version.
My own test results, python versions 3.8.2 and 3.8.3 can fix the problem, but python versions 3.8.1, 3.7.x, 3.6.x will cause the crash.
I can confirm that this happens with Python 3.7.x. Moving to 3.8.3 fixes the problem.
Workaround: boot in Safe Mode..
(Other apps are experiencing this.)
The macOS Window Server is crashing..
The Console.app contains the crash report in the "System Reports" node.
Process: WindowServer
Thread 0 (main thread) crashes in CGXBeginSurfaceLayerUpdate
I had the same problem with Mac OSX 10.14.6 completely crashing with no error messages and logging me out or rebooting. It was fixed by removing Anaconda and using the python.org ver 3.7.4. A good link for removing Anaconda is here. How to uninstall Anaconda completely from macOS
The new MacOS Catalina (Version 10.15) update seems to fix the problem for me. By specifying the tcl version and making sure the right tcl is used, I was able to successfully bundle and run my python script with tkinter. Yay!

Resources