No module named 'seaborn'

17 posts / 0 new
Last post
Humphrey
Offline
Joined: 10/13/2020 - 09:34
No module named 'seaborn'

Hello all,
I created a script in python which is supposed to generate a Bar chart using matplotlib. The module I am using for visualization is seaborn. While the script works perfectly when i invoke it from the editor and from command prompt, it gives the error 'No module named seaborn' whi i invoke it inside a macro. The module is however installed and working fine even when used in other scripts. I have spent three days trying to figure out whatthe problem could be to no avail.
 
Anyone who experienced this problem and was able to fix it?
I am using Python 3.6.8 64 bit and Version 11.3 of Idea, also 64 bit
 
 

klmi
Offline
Joined: 02/13/2019 - 08:41

Since IDEA 11 still isn't available in our country I don't know which Python version comes with IDEA 11.3. Please try to find out which modules are installed and run:
 
help('modules')
 
Nevertheless your problem sounds like you have installed a seperate Python version on your computer. But when running Python scripts from IDEA the integrated Python version is used. I guess also with IDEA 11.3 that version doesn't support Seaborn module. Unfortunately there's no possibility install additional modules via pip with IDEA's integrated Python version.

Humphrey
Offline
Joined: 10/13/2020 - 09:34

After running [help('modules')], i confirmed that the seaborn module was installed (please see atachment). The possibilty that the module could be missing in the integrated version of Python could be the cause of all these problems. I think i shall have to contact Caseware.

Images: 
Humphrey
Offline
Joined: 10/13/2020 - 09:34

Hello,
The version of Python that is integrated with IDEA is V 3.5.3. I want to install the same version on my computer and check if it will work.

Images: 
klmi
Offline
Joined: 02/13/2019 - 08:41

IDEA 10.4 also comes with Python 3.5.3 and the modules

  • scikit-learn 0.18.1
  • matplotlib 2.0.0
  • numpy 1.12.1+mkl
  • pandas 0.20.1
  • et_xmlfile 1.0.1
  •  jdcal 1.3
  •  jinja2 2.9.6
  • markupsafe 1.0
  • openpyxl 2.4.7
  • python-dateutil 2.6.0
  • cycler 0.10.0
  • SciPy 0.19.1
  • pypiwin32 219
  • pytz 2017.2
  • pyparsing 2.2.0
  • six 1.10.0

I don't believe there was any change with IDEA 11. 
Did you really run help('modules') from IDEA (f.e. PythonWin to see the output)?
That's my output since I have no separate Python installation running:
 
__future__          chunk               netbios             tarfile
_ast                cmath               netrc               telnetlib
_bisect             cmd                 nntplib             tempfile
_bootlocale         code                nt                  textwrap
_bz2                codecs              ntpath              this
_codecs             codeop              ntsecuritycon       threading
_codecs_cn          collections         nturl2path          time
_codecs_hk          colorsys            numbers             timeit
_codecs_iso2022     commctrl            numpy               timer
_codecs_jp          compileall          odbc                tkinter
_codecs_kr          concurrent          opcode              token
_codecs_tw          configparser        openpyxl            tokenize
_collections        contextlib          operator            trace
_collections_abc    copy                optparse            traceback
_compat_pickle      copyreg             os                  tracemalloc
_compression        crypt               pandas              tty
_csv                csv                 parser              turtle
_ctypes             ctypes              pathlib             turtledemo
_datetime           curses              pdb                 types
_decimal            cycler              perfmon             typing
_dummy_thread       datetime            pickle              unicodedata
_elementtree        dateutil            pickletools         unittest
_functools          dbi                 pipes               urllib
_hashlib            dbm                 pkg_resources       uu
_heapq              dde                 pkgutil             uuid
_imp                decimal             platform            venv
_io                 difflib             plistlib            warnings
_json               dis                 poplib              wave
_locale             distutils           posixpath           weakref
_lsprof             doctest             pprint              webbrowser
_lzma               dummy_threading     profile             win2kras
_markupbase         email               pstats              win32api
_md5                encodings           pty                 win32clipboard
_msi                ensurepip           py_compile          win32com
_multibytecodec     enum                pyclbr              win32con
_multiprocessing    errno               pydoc               win32console
_opcode             et_xmlfile          pydoc_data          win32cred
_operator           faulthandler        pyexpat             win32crypt
_osx_support        filecmp             pylab               win32cryptcon
_overlapped         fileinput           pyparsing           win32event
_pickle             fnmatch             pythoncom           win32evtlog
_pydecimal          formatter           pytz                win32evtlogutil
_pyio               fractions           pywin               win32file
_random             ftplib              pywin32_testutil    win32gui
_sha1               functools           pywintypes          win32gui_struct
_sha256             gc                  queue               win32help
_sha512             genericpath         quopri              win32inet
_signal             getopt              random              win32inetcon
_sitebuiltins       getpass             rasutil             win32job
_socket             gettext             re                  win32lz
_sqlite3            glob                regcheck            win32net
_sre                gzip                regutil             win32netcon
_ssl                hashlib             reprlib             win32pdh
_stat               heapq               rlcompleter         win32pdhquery
_string             hmac                runpy               win32pdhutil
_strptime           html                sched               win32pipe
_struct             http                scipy               win32print
_symtable           idlelib             select              win32process
_thread             imaplib             selectors           win32profile
_threading_local    imghdr              servicemanager      win32ras
_tkinter            imp                 setuptools          win32rcparser
_tracemalloc        importlib           shelve              win32security
_warnings           inspect             shlex               win32service
_weakref            io                  shutil              win32serviceutil
_weakrefset         ipaddress           signal              win32timezone
_win32sysloader     isapi               site                win32trace
_winapi             itertools           six                 win32traceutil
_winxptheme         jdcal               sklearn             win32transaction
abc                 jinja2              smtpd               win32ts
adodbapi            json                smtplib             win32ui
afxres              keyword             sndhdr              win32uiole
aifc                lib2to3             socket              win32verstamp
antigravity         linecache           socketserver        win32wnet
argparse            locale              sqlite3             winerror
array               logging             sre_compile         winioctlcon
ast                 lzma                sre_constants       winnt
asynchat            macpath             sre_parse           winperf
asyncio             macurl2path         ssl                 winreg
asyncore            mailbox             sspi                winsound
atexit              mailcap             sspicon             winxpgui
audioop             markupsafe          stat                winxptheme
base64              marshal             statistics          wsgiref
bdb                 math                string              xdrlib
binascii            matplotlib          stringprep          xml
binhex              mimetypes           struct              xmlrpc
bisect              mmap                subprocess          xxsubtype
builtins            mmapfile            sunau               zipapp
bz2                 mmsystem            symbol              zipfile
cProfile            modulefinder        symtable            zipimport
calendar            msilib              sys                 zlib
cgi                 msvcrt              sysconfig           
cgitb               multiprocessing     tabnanny

Humphrey
Offline
Joined: 10/13/2020 - 09:34

My apologies, i had run 'help('modules') from python. Below is an output after running the same on Pythonwin:
C:\Program Files\CaseWare IDEA\IDEA\lib\site-packages\matplotlib\cbook.py:136: MatplotlibDeprecationWarning: The matplotlib.delaunay module was deprecated in version 1.4. Use matplotlib.tri.Triangulation instead.
  warnings.warn(message, mplDeprecation, stacklevel=1)
IDEALib             cgi                 msvcrt              sysconfig
__future__          cgitb               multiprocessing     tabnanny
_ast                chunk               netbios             tarfile
_bisect             cmath               netrc               telnetlib
_bootlocale         cmd                 nntplib             tempfile
_bz2                code                nt                  textwrap
_codecs             codecs              ntpath              this
_codecs_cn          codeop              ntsecuritycon       threading
_codecs_hk          collections         nturl2path          time
_codecs_iso2022     colorsys            numbers             timeit
_codecs_jp          commctrl            numpy               timer
_codecs_kr          compileall          odbc                tkinter
_codecs_tw          concurrent          opcode              token
_collections        configparser        openpyxl            tokenize
_collections_abc    contextlib          operator            trace
_compat_pickle      copy                optparse            traceback
_compression        copyreg             os                  tracemalloc
_csv                crypt               pandas              tty
_ctypes             csv                 parser              turtle
_ctypes_test        ctypes              pathlib             turtledemo
_datetime           curses              pdb                 types
_decimal            cycler              perfmon             typing
_dummy_thread       datetime            pickle              unicodedata
_elementtree        dateutil            pickletools         unittest
_functools          dbi                 pipes               urllib
_hashlib            dbm                 pkg_resources       uu
_heapq              dde                 pkgutil             uuid
_imp                decimal             platform            venv
_io                 difflib             plistlib            warnings
_json               dis                 poplib              wave
_locale             distutils           posixpath           weakref
_lsprof             doctest             pprint              webbrowser
_lzma               dummy_threading     profile             win2kras
_markupbase         email               pstats              win32api
_md5                encodings           pty                 win32clipboard
_msi                ensurepip           py_compile          win32com
_multibytecodec     enum                pyclbr              win32con
_multiprocessing    errno               pydoc               win32console
_opcode             et_xmlfile          pydoc_data          win32cred
_operator           faulthandler        pyexpat             win32crypt
_osx_support        filecmp             pylab               win32cryptcon
_overlapped         fileinput           pyparsing           win32event
_pickle             fnmatch             pythoncom           win32evtlog
_pydecimal          formatter           pytz                win32evtlogutil
_pyio               fractions           pywin               win32file
_random             ftplib              pywin32_testutil    win32gui
_sha1               functools           pywintypes          win32gui_struct
_sha256             gc                  queue               win32help
_sha512             genericpath         quopri              win32inet
_signal             getopt              random              win32inetcon
_sitebuiltins       getpass             rasutil             win32job
_socket             gettext             re                  win32lz
_sqlite3            glob                regcheck            win32net
_sre                gzip                regutil             win32netcon
_ssl                hashlib             reprlib             win32pdh
_stat               heapq               rlcompleter         win32pdhquery
_string             hmac                runpy               win32pdhutil
_strptime           html                sched               win32pipe
_struct             http                scipy               win32print
_symtable           idlelib             select              win32process
_thread             imaplib             selectors           win32profile
_threading_local    imghdr              servicemanager      win32ras
_tkinter            imp                 setuptools          win32rcparser
_tracemalloc        importlib           shelve              win32security
_warnings           inspect             shlex               win32service
_weakref            io                  shutil              win32serviceutil
_weakrefset         ipaddress           signal              win32timezone
_win32sysloader     isapi               site                win32trace
_winapi             itertools           six                 win32traceutil
_winxptheme         jdcal               sklearn             win32transaction
abc                 jinja2              smtpd               win32ts
adodbapi            json                smtplib             win32ui
afxres              keyword             sndhdr              win32uiole
aifc                lib2to3             socket              win32verstamp
antigravity         linecache           socketserver        win32wnet
argparse            locale              sqlite3             winerror
array               logging             sre_compile         winioctlcon
ast                 lzma                sre_constants       winnt
asynchat            macpath             sre_parse           winperf
asyncio             macurl2path         ssl                 winreg
asyncore            mailbox             sspi                winsound
atexit              mailcap             sspicon             winxpgui
audioop             markupsafe          stat                winxptheme
base64              marshal             statistics          wsgiref
bdb                 math                string              xdrlib
binascii            matplotlib          stringprep          xml
binhex              mimetypes           struct              xmlrpc
bisect              mmap                subprocess          xxsubtype
builtins            mmapfile            sunau               zipapp
bz2                 mmsystem            symbol              zipfile
cProfile            modulefinder        symtable            zipimport
calendar            msilib              sys                 zlib
 

klmi
Offline
Joined: 02/13/2019 - 08:41

Well, as you likely know see "seaborn" is missing. For that reason IDEA's integrated Python version can't use that module and throws the error "No module named 'seaborn'".

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Humphrey,

As you have found out the Seaborn module is not included in the IDEA Python installation which uses 3.5.3.  From your description it sounds like you have created your own python environment which is perfectly understandable for development.  Unfortunately the IDEA Python environment doesn't have access to these modules, when you install python you can have multiple installations of python on your computer and they are segregated.  

If you wish to use seaborn in your IDEA application you need to have seaborn available directly to the importing script, this will usually mean that you have a copy of the module in the same directory as your calling script as python generally starts looking for modules in the current folder.  If you are distributing the script you will have to make sure that you also include the seaborn module in the distribution.

IDEA is relooking at this current structure as it doesn't allow for easy additional modules and such.  So this may change in the future.

Humphrey
Offline
Joined: 10/13/2020 - 09:34

Thanks Brian, thanks Klmi,
I removed all the fancy modules i had on the python script and confirmed it worked on my downgraded version of Python (Version 3.5.3). I executed the same script on Pythonwin, which is the Python that is integrated with IDEA. Despite that the python script worked flawlessly on the Python package that i have installed, i got the error 'unsupported operand type(s) for -: 'str' and 'float'' on Pythonwin. There are no mathematical computations on the script and i have been unable to identify what the cause of the issue is. Have you ever experienced this and if you have, how did you resolve it?

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Nope, never seen that before.   Do you at least have line numbers where you can go back and look at your code?

klmi
Offline
Joined: 02/13/2019 - 08:41

I've now tested the issue Humphrey rised with different versions of matplotlib. The following code doesn't work with matplotlib 2.0.0 but with 2.1.0 everything is fine:

import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'STRING':["A", "B", "C"], 'AMOUNT':[25, 40, 30]})
x = df['STRING']
y = df['AMOUNT']
plt.bar(x, y)
plt.show()

Unfortunately IDEA comes with a rather old version of matplotlib (2.0.0). That version throws an error when string arguments are set as x-values in matplotlib.pyplt.bar.

Workaround: 1) Use the index of the DataFrame as x-value and 2) mapping strings and index values with "xticks":

plt.bar(df.index, y)
plt.xticks(df.index, x)

Finally, one more argument that Caseware should give us the possiblity to manage the python modules.

Pages