0

I've installed most of my modules through Ubuntu packages, and consequently they're in /usr/lib/python3/dist-packages. Some are too old or not available through Ubuntu, so I've installed them through pip, and they're in /usr/local/lib/python3.3/dist-packages.

So far so good. However, both contain a package mpl_toolkits, but with different contents. import mpl_toolkits.basemap fails despite the presence of /usr/local/lib/python3.3/dist-packages/mpl_toolkits/basemap, because mpl_toolkits is found first in /usr/lib/python3/dist-packages/mpl_toolkits, which contains a number of modules, but not basemap.

So, in effect, the distribution-level mpl_toolkits is shadowing custom-installed mpl_toolkits. What is a correct way of handling this?

Levon
  • 138,105
  • 33
  • 200
  • 191
gerrit
  • 24,025
  • 17
  • 97
  • 170

1 Answers1

0

Normally, this should be taken care of by the packages __path__ attribute:

In [4]: mpl_toolkits.__path__ 
Out[4]: 
['/usr/local/lib/python3.3/dist-packages/mpl_toolkits',
 '/usr/lib/python3/dist-packages/mpl_toolkits']

However, if the second mpl_toolkits is installed after the first one was imported, it needs to be reloaded for mpl_toolkits to realise its distribution over multiple locations on the file system.

gerrit
  • 24,025
  • 17
  • 97
  • 170