How to work with matplotlib? - python

One of the graph generation files of Python is Matplotlib("http://matplotlib.org/").
I am using Python3.2.1 on Windows7(64bit) O/S.
I am trying to download the same to run matplotlib.animation.
If any one of the esteemed members of the group may kindly suggest me how to download
the same.
Thanks in Advance,
Regards,
Subhabrata Banerjee.
I can not import matplotlib.pyplot/matplotlib.pylab and if I have to download where from I may download? I am using Python3.2.1 on Windows7(64 bit).
But without a separate download how come matplotlib.animation is fine?
Regards,
Subhabrata.

I dont believe full support of python 3 has been added to matplotlib. Here is the status page.
It will support it on the next release.
If you want to use matplotlib with python. I believe you should use python 2.7 because Python 3 has massive changes that broke backward compatibility.

You can use pip to install the matplotlib by following command:
pip install matplotlib
It will automatically handle download and dependency task for you.
For how to install pip under Windows, refer here: How do I install pip on Windows?

Related

Installing python-socketio-client

Please excuse my lack of knowledge and poor terminology.
I am trying to get python-socketio-client running on my PI3B. It is used by some python code, not written by me, that takes selected data from Volumio3.x's API (under Buster), and passes it to my audio preamp controller to display it. The current Artist and Song Title.
It all worked on my PI2B with a version of Volumio 2.x under Jessie.
All my attempts to install python-socketio-client have errored.
I was wondering if I should install it with python3, and if so how?
Thanks
To install python packages usually you have to run pip install -m package-name
For Volumio if you check documentation (pyvolumio package) is this the one you are trying to use?
Only Python 3.7 and above are supported.
As you can see in: https://pypi.org/project/pyvolumio/

install opencv from source windows

I am trying to install OpenCV following this link https://docs.opencv.org/master/d5/de5/tutorial_py_setup_in_windows.html
opencv-4.5.1 is the version I am building from source. I have no errors in my entire process( up to Step 16)
Step 17 which INSTALL also has no errors, but Step 18 'import cv2 as cv' will not import this module.
I have python 3.9.1. I followed all the steps with CMAKE and was able to generate with no errors.
Is there something that I am missing here?
I would recommend to use another IDE like Pycharm to create your projects. It is extremely easy to setup an OpenCV work environment :).
IDLE is great for smaller projects but I`ve seen a lot of people having issues with it.

Matplotlib crashes when importing pyplot in Blender

I know this question has been asked many times before but I cannot find a solution that works for me. I'm running Python 3.5.3 under Blender 2.79 in Windows 10. As I require Blender 2.79, upgrading the Python version is not possible.
I've installed matplotlib and I can import it. However, when I try to import pyplot (e.g. import matplotlib.pyplot as plt), I get a crash to desktop with no error messages of any kind. This happens if I run Python externally or from inside Blender. The weird thing is that I was able to avoid this by changing backends to agg (matplotlib.use('agg')) and this is still working in a previous installation (so I know it's possible to get this to work !), but not in a separate, new installation of Blender. I've tried other backends but they make no difference.
The exact procedure I've tried is as follows :
Downloaded Blender 2.79 from a zip file (I'm using Windows 10) and unpacked it (call this directory /Blender/)
In /Blender/2.79/python/bin I run the command ./python -m ensurepip
In /Blender/2.79/python/scripts I run pip3 install --upgrade pip --user. This gives me pip3 version 20.2.4
In the same directory I run pip3 install --target="/Blender/2.79/python/lib/site-packages" matplotlib --upgrade. The "upgrade" switch is to prevent warnings that the "/bin" directory exists. Doesn't make any difference if I remove it, there's no existing installation of matplotlib. This gives me matplotlib version 3.0.3
Finally I start Python by /Blender/2.79/python/bin/python.exe, and do the above mentioned importmatplotlib.pyplot command which causes the crash.
I've tried this from a completely fresh installation of Blender, which comes with no existing external modules installed. Could there be some conflict with other Python modules elsewhere ? How would I go about diagnosing what's going on ?
Thanks for any ideas !
FIXED ! I remembered I found the solution months ago, but stupidly wrote down the answer in the wrong file...
The problem is that matplotlib is looking for a file that doesn't exist. In c:/users/me/.matplotlib (a hidden file), there's a file ""fontlist-vXXX.json", where XXX is the version number. This is set in line 951 of the file "font_manager.py", located in /python/lib/site-packages/matplotlib. In my case, the font_manager was looking for version 300 but the actual file was 310. Changing the version number in the font_manager.py made everything work correctly.

Python >=3.5.3 on Synology

i am trying to install Home Automatization (https://home-assistant.io) on my Synology. I've installed python via the synology packaging system, i've done basic setup (https://home-assistant.io/docs/installation/synology/) but when i try to run the daemon i see this in console:
homeassistant requires Python '>=3.5.3' but the running Python is 3.5.1
Is there any chance to update the python to required version on synology? Can you help me please?
Synology offers only python 3.5.1 at the moment.
You need to install older version of HA as mentioned on the installation page in blue box.
./python3 -m pip install homeassistant==0.64.3
If you would like to install latest HA, you would need to use docker instances on Synology, if your model supports it.
BTW.
Since the Python3 update (3.5.1-108) on Synology. once you install the HA you need to edit two files.
/volume1/#appstore/py3k/usr/local/bin/hass
and
/volume1/#appstore/py3k/usr/local/lib/python3.5/runpy.py
and add "import pip" to the beginning of the file where the import statements are. Otherwise HA will not start.
I've provided an updated python3-3.5.6 SPK for Synology in SynoCommunity; python3-3.6.8 is in the pipeline. Consider adding SynoCommunity ("spksrc") to your NAS to seamlessly install updates.
Additionally, be aware that home-assistant-0.82 is in beta at the same site.
Raw SPKs can be manually downloaded from my beta site if you want to check there as well, but I would suggest you look into SynoCommunity, keep updated from there, contribute comments and code there.

TVTK Error in Mayavi (Python)

I'm running a Fedora 17 (x64) machine, and I tried installing Mayavi for python via
yum install mayavi
which worked fine, except every time I write a code where I call a mayavi module (like mlab) :
from enthought.mayavi import mlab
it yells with the error
********************************************************************************
WARNING: Imported VTK version (5.8) does not match the one used
to build the TVTK classes (5.6). This may cause problems.
Please rebuild TVTK.
********************************************************************************
I've googled, but I don't know how to rebuild TVTK to match with the version of VTK. I suspect this is causing abnormal behaviour, but I can't be sure. How do you rebuild TVTK?
Looks like the visualization toolkit (http://www.vtk.org/) on your machine is newer than the one used to build the classes that are packaged in mayavi. You'd need to rebuild/install visualization toolkit 5.6 (http://vtk.org/VTK/resources/software.html) or have you tried Mayavi2 (http://docs.enthought.com/mayavi/mayavi/installation.html) - that is probably more up to date, visualization toolkit is currently version 5.10.
As of 4.3.1 do not yet support VTK 6.x. This is being worked on currently on master but is not finished yet.
https://github.com/enthought/mayavi/issues/124
I guess you used yum update but didn't do the trick. You can also check for the version in the repository by doing yum info and looking at the version number it displays.
If that does not satisfies you I'm afraid you will have to "use the source"...
hope this will help
I had the same problem and a simple update of mayavi2 did the trick:
pip install mayavi2 -U

Categories

Resources