how to include updated library in python code without root access? - python

I am working remotely on university systems.I wanted to include python's matplotlib1.1 and university system has matplotlib 0.98.
I did according to this post
How to install python modules without root access?
-bash-4.1$ easy_install --install=$HOME/lib/python2.6/site-packages matplotlib
Searching for matplotlib
Best match: matplotlib 0.98.3
Adding matplotlib 0.98.3 to easy-install.pth file
Using /opt/python/2.6/lib/python2.6/site-packages
Processing dependencies for matplotlib
Finished processing dependencies for matplotlib
But still I am not able to use modules in new version
I am getting importerror for animation which is there only in updated version.

Try the following import to import a specific version.
import pkg_resources
pkg_resources.require("matplotlib==0.98.3")
import matplotlib

Related

import rpy2 but can not import rpy2.robjects when changing start folders

The Current problem I am looking into is described below:
My computer is Win10, I installed only one anaconda 3.5.3 on it. Using where python there is only one python in my computer.
I downloaded a rpy2python wheel file from the uefi website, and install that using pip install.
When I import rpy2 in C disk, it is already fine, import rpy2,import rpy2.robjects are all OK.
But when I import rpy2 in my own project, I can only first import rpy2, when I import rpy2.robjects,the program says can not find rpy2 module.
Finally I found the problem is that in my project, I occasionaly established an rpy2.py file, when I first import rpy2, it where automatically create an rpy2.pycache folder, secondly when I import rpy2.robjects, Of Course the computer can not find an rpy2.robjects.
Just Keep a track of my problem.
You'll want to check the Python documentation about import rules for modules. By default, having a file called rpy2.py in the working directory for your Python code will cause import rpy2 to find this one rather that the rpy2 package.
The easiest fix is probably to rename your module rpy2.py into something else.

How to add matplotlib from python3.6 to Blender?

In Window, I installed python3.6
and, installed matplotlib by commandline:
pip install matplotlib
After installation, I was running matplotlib in python console,
import matplotlib.pyplot as plt
import matplotlib.pylab as plb
In python36\lib\site-packages
I want in blender to use the matplotlib library in python,
Can I copy the matplotlib in python36\lib\site-packages of Python into the Blender\2.78 \python\lib\site-packages?
I tried copying but only importing matplotlib, but when `import matplotlib.pylot as plt the error is as follows
I do not know how to fix it, please help me
Thank you so much!
First you will want to make sure you use the same python version as blender was built with, for blender 2.78 that is python 3.5. For compiled python modules like matplotlib this is more important than pure python modules.
There are few ways to use third party modules, first like you are trying, is to install them into blender's copy of python. Another way is to delete blender's python so that it uses the system installed version. You can also adjust sys.path to allow blender's python to find third party modules.

Matplotlib: Import Error no module named _path

I've been struggling for hours on a problem that is making me insane. I installed Python 2.7 with Cygwin and added Scipy, Numpy, Matplotlib (1.4.3) and Ipython. When I decided to run ipython --pylab I get the following error:
/usr/lib/python2.7/site-packages/matplotlib/transforms.py in <module>()
37 import numpy as np
38 from numpy import ma
----> 39 from matplotlib._path import (affine_transform, count_bboxes_overlapping_bbox,
40 update_path_extents)
41 from numpy.linalg import inv
ImportError: No module named _path
I spent hours on the internet, looking for a solution but nothing worked. I did notice that I am missing _path.so files in the matplotlib directory that everybody seems to have. Instead, I have two files: path.py and path.pyc. But I installed matplotlib directly from the official website using pip install and reinstalling it didn't make any difference. Does anyone have a little clue on what is going wrong? I would be incredibly grateful !!!
For others having this problem, in my case, the solution was simple. The problem was caused by having the wrong matplot library installed on your computer; creating an error in finding the correct matplotlib path. In my case, I had installed matplotlib on a different version of python. Simply update matplotlib on your computer, so that it is compatible with your current version of python:
pip install --upgrade matplotlib
As for the post, I am unsure of what caused these big issues. Hope my tip can help anyone else stumbling upon this issue!
I doubt that most of you brought here by Google have the problem I had, but just in case:
I got the above "ImportError: No module named _path" (on Fedora 17) because I was trying to make use of matplotlib by just setting sys.path to point to where I had built the latest version (1.5.1 at the time). Don't do that.
Once I ran "python setup.py install" (as root) to do a proper install (and got rid of my sys.path hack), the error was fixed.
The package matplotlib requires multiple dependencies (see them here). For me, the missing dependencies included pyparsing and kiwisolver, but your results my vary. Before you do any of these other things (reinstalling python or the library, etc...), make sure you have installed (pip install ...) all the libs in this list (link).

Trouble in installing Basemap in matplotlib

I am trying to install Basemap, and beforehand I already have the prerequisite versions of Matplotlib, Python and Numpy working on my Mac. To install Basemap I am following the instructions in this website http://matplotlib.org/basemap/users/installing.html
I seemed to progress quite well with the steps, until the very end which is "Check your installation by running from mpl_toolkits.basemap import Basemap at the python prompt." I got "ImportError: cannot import name pyproj" from a line that reads "---> 30 from mpl_toolkits.basemap import pyproj".
Does anyone have any idea? Many thanks!
The compiled module could be accessible by python. To achieve that you should put the module into python path or you need to add the location of the module to PYTHONPATH environment variable.
To see the python installations paths you can write these lines to python shell:
import sys
for path in sys.path:
print(path)
The code will show the paths python is looking for modules.
After you compile the c library, you need to go to upper folder and run python setup.py install as it's said in the installation page. This will put python modules into one of your python paths.
I had the same problem installing basemap-1.0.7.
I found that the file
/usr/lib64/python2.6/site-packages/mpl_toolkits/basemap/init.py
had a reference to axes-grid1, but python lists only module axes_grid.
So I changed grid1 to grid and now basemap imports without error.
Had the same issue on OSX, found after much faffing that Basemap worked fine with a non-native version of python (for me 2.7.12 with everything under /opt/local/Library/Frameworks...) but not with the native version (for me 2.7.10 with most stuff under /System/Library/Frameworks... and Basemap under /Library/...). I did note also that under the native version there was already some mpl_tooklit content and without the permission to add Basemap there you end up with mpl_toolkit contents in multiple places. I wasn't sure if this was the problem specifically but as I said having it all under opt using non-native python was what solved this for me.

Unable to import FigureCanvasWxAgg from Matplotlib in Python

I'm using Python x64 with everything installed, but I'm getting an unresolved import on FigureCanvasWxAgg. I can get up to matplotlib.backends.backend_wxagg but there's no FigureCanvasWxAgg to import from there.
I've also tried
from matplotlib.backends.backend_wxagg import * but it doesn't work either.
EDIT: Problem solved. I took a peek at my backend_wxagg.py file and found it to be completely different than the one listed here. So I copied that from version 0.99.1.1 into my 1.0.1 file. (I should probably just uninstall 1.0.1 matplotlib and use the older version.) Anyway, it got the examples working, so I'm happy.
What OS are you on, and how did you install matplotlib?
Your solution is quite likely to break things... You need to build and install the wx backend as you normally would. I'm not sure about the wx backend, but several of the other backends are C extensions, not just a simple python file.
The wx backend isn't built by default, so it's usually included as a separate package. (e.g. python-matplotlib-wx in the case of Suse) You'll need to install the wx backend through your package manager, as you normally would.
If you're on an OS without a package manager (e.g. windows, osx), the installer may or may not have the wx backend built depending on who built it and how it was configured. I know absolutely nothing about non-linux or BSD oses, so you're on your own there. Try looking wherever you downloaded your matplotlib binary from and see if they have a separate installer for the wx backend.
If you're building from source, you need to enable the wx backend and rebuild. To do this, edit the site.cfg file in your build directory. You may need to rename the default one (site.cfg.default, or something along those lines) to site.cfg, if you don't alread have a site.cfg file in your build directory.
Hope that helps!

Categories