Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Errors in installation of matplotlib and pandas on Macbook

29 views
Skip to first unread message

Madhavan Bomidi

unread,
Jun 29, 2016, 11:51:56 PM6/29/16
to
Hello everyone,

I am very new to Macbook and python. I have installed python through MacPorts and when I check if all the packages I required are installed properly, I get the following traceback errors for matplotlib and pandas packages. Can anyone suggest me how I can rectify the same? I tried to check the file "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py" using vim command but it is empty. Please suggest me ...

Bomidis-MacBook-Pro:~ madhavan$ which python
/usr/local/bin/python
Bomidis-MacBook-Pro:~ madhavan$ which ipython
/usr/local/bin/ipython
Bomidis-MacBook-Pro:~ madhavan$ python -V
Python 2.7.11
Bomidis-MacBook-Pro:~ madhavan$ python
Python 2.7.11 (default, Jun 17 2016, 20:01:51)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> print(numpy.version.full_version)
1.11.1
>>> import scipy
>>> print(scipy.version.full_version)
0.17.1
>>> import netCDF4
>>> import h5py
>>> import nltk
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1131, in <module>
rcParams = rc_params()
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params
return rc_params_from_file(fname, fail_on_error)
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file
config_from_file = _rc_params_in_file(fname, fail_on_error)
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
encoding = locale.getdefaultlocale()[1]
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 543, in getdefaultlocale
return _parse_localename(localename)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 39, in <module>
from pandas.core.api import *
File "/Library/Python/2.7/site-packages/pandas/core/api.py", line 10, in <module>
from pandas.core.groupby import Grouper
File "/Library/Python/2.7/site-packages/pandas/core/groupby.py", line 18, in <module>
from pandas.core.frame import DataFrame
File "/Library/Python/2.7/site-packages/pandas/core/frame.py", line 39, in <module>
from pandas.core.series import Series
File "/Library/Python/2.7/site-packages/pandas/core/series.py", line 2944, in <module>
import pandas.tools.plotting as _gfx # noqa
File "/Library/Python/2.7/site-packages/pandas/tools/plotting.py", line 27, in <module>
import pandas.tseries.converter as conv
File "/Library/Python/2.7/site-packages/pandas/tseries/converter.py", line 7, in <module>
import matplotlib.units as units
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1131, in <module>
rcParams = rc_params()
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 975, in rc_params
return rc_params_from_file(fname, fail_on_error)
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1100, in rc_params_from_file
config_from_file = _rc_params_in_file(fname, fail_on_error)
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1018, in _rc_params_in_file
with _open_file_or_url(fname) as fd:
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 1000, in _open_file_or_url
encoding = locale.getdefaultlocale()[1]
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 543, in getdefaultlocale
return _parse_localename(localename)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

----------------

Look forward to your response,
Thanks and regards,
Madhavan

Lawrence D’Oliveiro

unread,
Jun 30, 2016, 12:02:04 AM6/30/16
to
On Thursday, June 30, 2016 at 3:51:56 PM UTC+12, Madhavan Bomidi wrote:

> Bomidis-MacBook-Pro:~ madhavan$ which python
> /usr/local/bin/python

Apple already includes a(n obsolete) version of Python with its OS. Trying to override this with a newer version could easily lead to conflicts.

Madhavan Bomidi

unread,
Jun 30, 2016, 12:27:41 AM6/30/16
to
Can you please suggest me what I shall do to make sure all the libraries that I have indicated above work in python? I don't know how I can get back to obsolete version of Python. Please suggest me the commands or references of previous posts, if any.

Thanks and regards,
Madhavan

Chris Angelico

unread,
Jun 30, 2016, 12:49:21 AM6/30/16
to
On Thu, Jun 30, 2016 at 1:51 PM, Madhavan Bomidi <blmad...@gmail.com> wrote:
> File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
> raise ValueError, 'unknown locale: %s' % localename
> ValueError: unknown locale: UTF-8

This looks like a problem in your environment. "UTF-8" is not a
locale; usually you'll want something else first. For me, it's
"en_AU.utf8" (although I believe UTF-8 works fine in place of utf8).
What language do you primarily speak, and what country are you in? Put
their two-letter codes together, and you'll get something like
"en_US.utf8" (English, USA), or "tr_TR.utf8" (Turkish, Turkey), or
"pt_BR.utf8" (Portuguese, Brazil). Once you know what locale you want
to be using, though, you'll need someone who knows Macs to help you
select that appropriately. Worst case, run this command before
starting Python:

export LC_ALL=en_AU.utf8

That may help.

ChrisA

Madhavan Bomidi

unread,
Jun 30, 2016, 1:55:03 AM6/30/16
to
Hello ChrisA,

Thanks for your suggestion. My script works fine when I run the command 'export LC_ALL=en_AU.utf8' before starting python.

I am from India and using US English and international keyboard. I also tried using the command 'export LC_ALL=en_USA.utf8' and the python script works fine. How can I avoid running this command everytime when I want to start Python?

Can I add the following two lines to .bash_profile?

export LC_CTYPE=en_US.utf8
export LC_ALL=en_US.utf8

Look forward to your response.
Thanking you in advance,
Madhavan


Chris Angelico

unread,
Jun 30, 2016, 2:02:37 AM6/30/16
to
On Thu, Jun 30, 2016 at 3:54 PM, Madhavan Bomidi <blmad...@gmail.com> wrote:
>
> Thanks for your suggestion. My script works fine when I run the command 'export LC_ALL=en_AU.utf8' before starting python.
>
> I am from India and using US English and international keyboard. I also tried using the command 'export LC_ALL=en_USA.utf8' and the python script works fine. How can I avoid running this command everytime when I want to start Python?
>
> Can I add the following two lines to .bash_profile?
>
> export LC_CTYPE=en_US.utf8
> export LC_ALL=en_US.utf8

That would possibly work, but more likely, there'll be some way in
your Mac's configuration/settings menus to set your locale. If you get
that set correctly, you should be able to leave those lines out of
your .bash_profile and still have everything work.

ChrisA

Madhavan Bomidi

unread,
Jun 30, 2016, 2:21:59 AM6/30/16
to
Hello ChrisA,

Thanks for your suggestion. I have typed the following on Terminal:

$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL="C"

How should I modify the profile/configuration of locale permanently? Is it possible to do this on terminal other than using 'export' command always and including the commands in .bash_profile?

How does this locale configuration affect other processes or software on the Macbook?

I also get another problem with selfupdate of Mac port. Below is the error message. Is this a problem of configuration in the locale?

------------------
$ port -v selfupdate
---> Updating MacPorts base sources using rsync
rsync: failed to connect to rsync.macports.org: Operation timed out (60)
rsync error: error in socket IO (code 10) at /BuildRoot/Library/Caches/com.apple.xbs/Sources/rsync/rsync-47/rsync/clientserver.c(105) [receiver=2.6.9]
Command failed: /usr/bin/rsync -rtzv --delete-after rsync://rsync.macports.org/release/tarballs/base.tar /opt/local/var/macports/sources/rsync.macports.org/release/tarballs
Exit code: 10
Error: Error synchronizing MacPorts sources: command execution failed
To report a bug, follow the instructions in the guide:
http://guide.macports.org/#project.tickets
Error: /opt/local/bin/port: port selfupdate failed: Error synchronizing MacPorts sources: command execution failed
-------------------------------

Chris Angelico

unread,
Jun 30, 2016, 3:03:30 AM6/30/16
to
On Thu, Jun 30, 2016 at 4:21 PM, Madhavan Bomidi <blmad...@gmail.com> wrote:
> How should I modify the profile/configuration of locale permanently? Is it possible to do this on terminal other than using 'export' command always and including the commands in .bash_profile?
>
> How does this locale configuration affect other processes or software on the Macbook?
>
> I also get another problem with selfupdate of Mac port. Below is the error message. Is this a problem of configuration in the locale?

These are all Mac-specific questions (and not, incidentally,
Python-specific). You'll probably find you can learn a lot from
Googling your problems. (Or DuckDuckGoing them, but that doesn't roll
off the tongue so easily.)

ChrisA

tommy yama

unread,
Jun 30, 2016, 8:48:29 AM6/30/16
to
Hi there,

Why you would not use pip and anaconda for panda installation?
It seems much easier to do the same.

<https://www.continuum.io/downloads#_macosx>
<https://www.continuum.io/downloads#_macosx>
<https://www.continuum.io/downloads#_macosx>
https://www.continuum.io/downloads#_macosx


*Tomomi Yamano *




On Thu, Jun 30, 2016 at 4:03 PM, Chris Angelico <ros...@gmail.com> wrote:

> On Thu, Jun 30, 2016 at 4:21 PM, Madhavan Bomidi <blmad...@gmail.com>
> wrote:
> > How should I modify the profile/configuration of locale permanently? Is
> it possible to do this on terminal other than using 'export' command always
> and including the commands in .bash_profile?
> >
> > How does this locale configuration affect other processes or software on
> the Macbook?
> >
> > I also get another problem with selfupdate of Mac port. Below is the
> error message. Is this a problem of configuration in the locale?
>
> These are all Mac-specific questions (and not, incidentally,
> Python-specific). You'll probably find you can learn a lot from
> Googling your problems. (Or DuckDuckGoing them, but that doesn't roll
> off the tongue so easily.)
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
0 new messages