Matplotlib won't install properly on Python 3.5 - python

I've just installed Python 3.5 to experience its functionality. The problem is that all the modules I use in my daily programming have been installed and run very well on it except Matplotlib. I installed it via pip and never faced any errors while installing, but when I wanted to import it, the error saying, DLL load failed: The specified module could not be found. popped up.
What's the matter with Python 3.5, or Matplotlib?

Uninstall the module using pip uninstall matplotlib then install it again using http://matplotlib.org/downloads.html
Obtain the .exe file that best fits your machine, in my case it would be matplotlib-1.4.3.win-amd64-py3.4.exe. This will be a more complete version of matplotlib for windows rather than using pip.
I would also consider rolling back to Python 3.4 unless you absolutely need 3.5. There shouldn't be a compatibility issue between 3.4 and 3.5 for Python, but as far as matplotlib it's been tested with 3.4, but if you run through problems on 3.5 I would roll back.

If you have Python 3.5 you should install MS's Redistributable DLLs to make matplotlib working on Windows... In my case, no need to reinstall matplotlib even...
Try this example without. If error appears install that and try with it (you must log in MS site and download version for arch you using - i tested x86 only, Windows 7, Python 3.5).
That case is included in matplotlib install documentation!
Remember, you should always read documentation before you ask!

Related

Import matplotlib in python3 failed after successfully installed matplotlib

After successfully installed matplotlib via the terminal (ubuntu18.04 and VM5.2.44), I could use this package smoothly in python 2.7, but not in python3. I know this should be an environment issue. Could somebody kindly point out how to set up the environment in order for me to use this package (along with some other packages) in both python 2.7 and python3?
Thanks for any suggested details here.

Python 3.7 cmath module import error

i installed python3.7 on ubuntu using ppa:deadsnakes/ppa repository.
When I try to run
import cmath
in python shell it fails with message:
ModuleNotFoundError: No module named 'cmath'
I didn't find any info about depracation of this library or anything in python3.7 changelog. It works fine in pythons 3.5 and 2.7. I tried installing it on different ubuntu virtual machines and computers and I always get the same result.
Do I need to install some specific library or something (which I doubt because the module is listed in standard library https://docs.python.org/3/library/index.html) or is problem elsewhere?
This was a bug in the deadsnakes backport of python3.7 specifically for xenial.
During the 3.7 beta period (when the package was imported). The cpython build system used PY_CORE_CFLAGS as a make variable. It was later changed to PY_STDMODULE_CFLAGS. debian ships a patch with their package that adjusts a generated makefile line using a sed expression for that specific variable. Since this was missing it caused the cmath module to build incorrectly.
This has been fixed in this commit
This fix is available in 3.7.0-1+xenial2 (debian version)
I installed python3.7 by downloading and installing it using make and cmath started working. It looks like ppa:deadsnakes/ppa repository had missing cmath module.

Installing MayaVi on Windows, working with Python 2.7

I am trying to install the MayaVi package using pip, but I keep getting an error message saying (ImportError: No module named vtk). How do I fix this problem?
So on command prompt:
$pip install mayavi
output
File "Tvtk\code_gen.py", line 10, in
import vtk
ImportError: No module named vtk
This has actually gotten a lot easier with the new wheel format and installation.
Make sure your python setup is wheel compatible (e.g. upgrade pip and 'pip install wheel') - you may need to google around for how to do that for certain distributions like Canopy.
Then just grab either the VTK and MAYAVI wheels or the MAYAVI+VTK wheel from the inestimable http://www.lfd.uci.edu/~gohlke/pythonlibs/#vtk
Right now for example you might choose: mayavi‑4.4.0+vtk610‑cp27‑none‑win32.whl
(assuming 32 bit install of cpython 2.7, the filenames encode important stuff and there are many options)
Then run pip install mayavi‑4.4.0+vtk610‑cp27‑none‑win32.whl
I just had the occasion to do this on a laptop that I hadn't set up with Mayavi yet and it ran smooth as silk and installed everything I needed without complaint. That was several steps smoother than the last time I had to install Mayavi on a windows machine.
From my recent experience, one possible reason is that vtk for windows is not installed prior to using mayavi.
however you can't do pip install vtk.
you can get vtk from here
also, remember to configure VC Express 2008 and Windows 7 SDK + .NET 3.5 to avoid additional errors.

Pylab after upgrading

Today I upgraded to Xubuntu 13.04 which comes with Python 3.3. Before that, I was working with Pyton 3.2, which was working perfectly fine.
When running my script under Python 3.3, I get an
ImportError: No module named 'pylab'
in import pylab.
Running in Python 3.2, which I reinstalled, throws
ImportError: cannot import name multiarray
in import numpy.
Scipy, numpy and matplotlib are, recording to apt, on the newest version.
I don't have much knowledge about this stuff. Do you have any recommendations on how to get my script to work again, preferably on Python 3.2?
Thanks in advance,
Katrin
Edit:
We solved the problem: Apparently, there where a lot of fragments / pieces of the packages in different paths, as I installed from apt, pip as well as manually. After deleting all packages and installing them only via pip, everything works fine. Thank you very much for the help!
I suspect you need to install python3-matplotlib, python3-numpy, etc. python-matlab is the python2 version.
You need to install all python libraries you installed for Python 3.2 also for 3.3.

After installing matplotlib basemap via Macports, example python code for basemap is not running

I'm using Mac OS X 10.6.8. I installed Python 2.6 using the binary installer in http://www.python.org/. I've been using it along with SciPy and Matplotlib for my scientific computing needs since March 2011 without any problems. Recently, I have the need for the matplotlib library called Basemap.
I followed this article on https://modelingguru.nasa.gov/docs/DOC-1847. It states that the easiest way to install the Basemap library is through Macports (or Fink). So I tried to install Basemap via Macports. I executed the command
port install py-matplotlib-basemap
and it seems to install so many things such as Python 2.4, etc. So to be specific, I used Macports again but this time using
port install py26-matplotlib-basemap
since I'm using Python 2.6. The installation didn't seem to have any problems.
Now I tested if Basemap was properly installed by running a Python code example that uses basemap for graphing. But the terminal says the following before coming back to the prompt:
Traceback (most recent call last):
File "basemap-test.py", line 1, in <module>
from mpl_toolkits.basemap import basemap
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/mpl_toolkits/basemap/__init__.py", line 45, in <module>
import _geoslib, netcdftime
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/_geoslib.so, 2): Symbol not found: _GEOSArea
Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/_geoslib.so
Expected in: dynamic lookup
What may be wrong here? I know that Macports installs its own Python version, I don't know if that has an effect on this problem.
As you noted, MacPorts installs its own Python version (by default, at /opt/local/bin/python2.6). If you install a Python package via MacPorts, like basemap, you normally will need to run everything under the MacPorts Python. Don't try to mix and match Python instances. Packages that include C extension modules or depend on other packages which include C libraries have to be built in a way that is compatible with the way the Python interpreter was built. The Python 2.6 installers from python.org are 32-bit-only and built to be compatible with a range of OS X versions. By default, what MacPorts builds will be 64-bit on 10.6, if possible, and only tailored for 10.6 systems. The safest and easiest option long term would be to switch to using the MacPorts Python, ensuring that all the packages you need are installed from MacPorts.

Categories