1

I know many questions speak about this problem, but i tried a lot and didn't fin any solution to my "very classical" issue : Python import fails altough package installed:

MacBook-Pro-de-Stephanie:scripts user$ sudo -H pip install openpyxl
Collecting openpyxl
Requirement already satisfied (use --upgrade to upgrade): jdcal in /usr/local/lib/python2.7/site-packages (from openpyxl)
Requirement already satisfied (use --upgrade to upgrade): et-xmlfile in /usr/local/lib/python2.7/site-packages (from openpyxl)
Installing collected packages: openpyxl
Successfully installed openpyxl-2.3.5

Package installed right ?

MacBook-Pro-de-Stephanie:scripts user$ python interactionsXLSX2CSV.py 
Traceback (most recent call last):
  File "interactionsXLSX2CSV.py", line 5, in <module>
    from openpyxl import load_workbook
ImportError: No module named openpyxl

Fails right ?

MacBook-Pro-de-Stephanie:scripts user$ echo $PYTHONPATH
/usr/local/lib/python2.7/:

Path seems ok, no ?

I set permissions with:

sudo chmod -R ugo+rX ./lib/python2.7/site-packages/

What can i try else ? Thank you very much

Max
  • 19
  • 5

2 Answers2

0

Here was the solution for me (linked to Mac OS clearly) : Can't load Python modules installed via pip from site-packages directory

/usr/bin/python is the executable for the python that comes with OS X. /usr/local/lib is a location for user-installed programs only, possibly from Python.org or Homebrew. So you're mixing different Python installs, and changing the python path is only a partial workaround for different packages being installed for different installations.

In order to make sure you use the pip associated with a particular python, you can run python -m pip install <pkg>, or go look at what the pip on your path is, or is symlinked to.

Community
  • 1
  • 1
Max
  • 19
  • 5
-1

I am not getting that error. Just now i installed. All i am getting is

" /usr/local/lib/python2.7/dist-packages/openpyxl/xml/init.py:15: UserWarning: The installed version of lxml is too old to be used with openpyxl warnings.warn("The installed version of lxml is too old to be used with openpyxl")"

Once try by using below command.

sudo apt-get install python-openpyxl
swetha
  • 67
  • 8