Matplotlib cannot find Font family [u'sans-serif'] - python-2.7

I installed matplotlib 2.2.3 using anaconda (with python 2.7.16). I always have this missing font problem on the higher versions of matplotlib (> 1.5.1).
/home/satadru/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:1331: UserWarning: findfont: Font family [u'serif'] not found. Falling back to DejaVu Sans(prop.get_family(), self.defaultFamily[fontext]))
I know there are many solutions available on the web but nothing solved my problem. I already tried the following suggestions, but none of them helped:
sudo apt-get install msttcorefonts -qq
sudo apt install font-manager
rm ~/.cache/matplotlib -fr
I just don't want to go back to an older version of matplotlib again just to avoid the problem. Please help. My code is
from matplotlib import rcParams
rcParams['font.family'] = 'sans-serif'
rcParams['font.sans-serif'] = ['Tahoma']
import matplotlib.pyplot as plt
.......................

Related

Anaconda - Spyder 3.3.6 - Python 2.7 - no module named matplotlib

I'm trying to use matplotlib on spyder 3.3.6 but I'm having trouble importing it in the first place, is there some way to install matplotlib beforehand? I don't have a very specific question, I guess I'm just requesting someone to help me with this. I'm pretty new to using python
import matplotlib.pyplot as plt
and it returns " ImportError: No module named matplotlib.pyplot "
when I run
pip install matplotlib
I get
pip install matplotlib
^
SyntaxError: invalid syntax

python - pip installs but cannot import

I've read a lot of posts about this but none of the solutions have worked for me. I'm trying to get a module called nsxramlclient installed, shows successful installation with pip but cannot import from any location outside of the /Users/Nathan/Library/Python/2.7/lib/python/site-packages.
Uninstall does work after some fidgeting with brew using the recommendations found with brew doctor. Here are some vitals:
Running OSX python 2.7.10
PIP 18.1
which -a pip = /usr/local/bin/pip
which -a python = shows 2 directories:
/usr/local/bin/python
/usr/bin/python
python -c 'import sys; print(sys.path)'
['', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python#2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload']
pip list | grep nsxramlclient
nsxramlclient 2.0.7
It has to be a path issue since I'm able to import it from the directory that the module is located. I just don't know the proper method to repair this since I'm fairly new to Python and I don't want to mess it up worse that it is already.
Looks like I did end up getting it to work finally. What I had to do was to re-install python with brew:
brew re-install python#2
then I needed to re-install the modules I needed with pip. Having OTHER issues now but at least this one is fixed.

ROS Kinetic: No script named 'rosdep' although it is installed

I have a problem using ROS Kinetic in Ubuntu 16.04.
It was working normally but suddenly rosdep dissapeared while I was trying to configure the Turtlebot Simulator and the AR Drone Autonomy Package.
When I type sudo rosdep init it shows the next error
Traceback (most recent call last):
File "/usr/local/bin/rosdep", line 4, in <module>
__import__('pkg_resources').run_script('rosdep==0.11.5', 'rosdep')
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 739,in run_script
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 1486, in run_script
pkg_resources.ResolutionError: No script named 'rosdep'
I tried to install rosdep manually with sudo apt-get install python-rosdep but it shows that python-rosdep is already the newest version (0.11.5-1)
I tried uninstalling ROS using sudo apt-get purge ros-* and sudo apt-get autoremove and installing it again.
And also reinstalling it using sudo apt-get install --reinstall ros-kinetic-desktop-full but no working.
I am following the instructions of the official
site .
Any idea of what can I do to solve this? Thanks
rosdep is actually completely independent from all the ros-** packages because it is used to install them, which is why reinstalling those packages didn't help.
My best guess would be that you used pip in addition to apt for something with rosdep, and now have 1.5 or 3 different versions of rosdep. Please try removing rosdep installed using apt completely:
apt-get purge python-rosdep and make sure that there are no errors when removing the package. If there are any, post them as comment here. Then, check all python import paths for a folder named rosdep, and remove them. You can find out your python import paths by running the following python script:
import sys
print sys.path
Then, you type which rosdep. If there is a rosdep binary anywhere, remove it. Then you can reinstall rosdep: sudo apt install python-rosdep.

nltk module installation in pip through cmd

When I tried to run this command:
c:\python27\scripts\pip install nltk-3.2.1-py2.py3-none-any
I am getting the error:
no matching distribution found
Although i have installed nltk from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#nltk
Kindly help.
I am working on Windows 8 64-bit Version
Installing new modules can be a nightmare if you are new to Python.First delete any old versions of NLTK if already installed. Open cmd navigate to C:\Users\user\AppData\Local\Programs\Python\Python35-32\Scripts, the default directory, using the command cd path_name_comes_here. Otherwise goto the path where you have installed python and goto the Scripts subfolder and use this path here onwards. Now the most preferred way is to use pip install module_you_want_to_install for anything in python. Pip automatically fetches everything it needs to install said module.
Simply use pip install nltk.
Another method is to use easy_install requirement_or_URL.
Some rare occasions its best to download the wheel from http://www.lfd.uci.edu/~gohlke/pythonlibs and from there you can simply use pip install downloaded_wheel_name again. But make sure to copy the name of the wheel EXACTLY.
Post installation make sure that your package is accessible from C:\Users\user\AppData\Local\Programs\Python\Python35-32\Lib\site-packages or a similar path depending on where you installed python.
Try Anaconda - Instead . Always works
C:\Users\sanan>conda install -c anaconda nltk
Fetching package metadata .............
Solving package specifications: .
Package plan for installation in environment C:\Users\sanan\Miniconda3:
The following NEW packages will be INSTALLED:
nltk: 3.2.4-py36_0 anaconda
The following packages will be UPDATED:
conda: 4.3.23-py36_0 --> 4.3.25-py36_0 anaconda
The following packages will be SUPERSEDED by a higher-priority channel:
conda-env: 2.6.0-0 --> 2.6.0-0 anaconda
Proceed ([y]/n)? y
conda-env-2.6. 100% |###############################| Time: 0:00:00 22.84 kB/s
nltk-3.2.4-py3 100% |###############################| Time: 0:00:02 774.24 kB/s
conda-4.3.25-p 100% |###############################| Time: 0:00:00 578.90 kB/s
After installation is complete .
import nltk
print(nltk.__version__)
C:\Public\Code\textnorm>python attempt1.py
3.2.4

Matplotlib Basemap Installation Troubles on OS X Yosemite

I've been having very serious issues installing Basemap from mpl_toolkits. Fortunately, it looks like I'm not the only one having these issues... I was wondering if someone could help me here.
I'm currently running OS X 10.10 (Yosemite).
Long story short, I was able to install Basemap via Anaconda after much difficulties. Now whenever I try to import Basemap, I get the following error:
28 from matplotlib.lines import Line2D
29 from matplotlib.transforms import Bbox
---> 30 from mpl_toolkits.basemap import pyproj
31 from mpl_toolkits.axes_grid1 import make_axes_locatable
32 from matplotlib.image import imread
ImportError: cannot import name pyproj
...which doesn't make sense to me at all. I have pyproj installed, and I physically see it in my Anaconda pkgs folder. It's called pyproj-1.9.3-0. I also have basemap-1.0.7-np19py27_0 in my pkgs folder.
Does anyone have any idea what's going on? Maybe I stupidly forgot to do something? Sorry if it's a dumb question - I'm an amateur when it comes to these sorts of things.
I just managed to install Basemap on Yosemite with Anaconda without any problems, so maybe there's something unusual about your set-up (what issues are you refering to?)
What I did was simply
conda install Basemap
But here are some things to think about:
Did you install anything after issuing this command (on my system, conda updated my matplotlib to 1.4.3 as part of this installation. You could try conda update, but you might need to do some fixing if you changed anything "by hand".
Are you using the right virtual environment (the one from which you installed Basemap)?
import Basemap with from mpl_toolkits.basemap import Basemap rather than the import Basemap that your question implies: see e.g. this example.
type which python and check that the output is along the lines of
/Users/<username>/anaconda/bin/python
or
/Users/<username>/anaconda/envs/<virtual-env>/bin/python
and that you're not using your Mac's system Python which would be something like
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python