A small issue with Swan and Excel file reading

Dear All,
I am using a Notebook on Swan using the latest software stack.
I am using the following command

SPS_cycle = pnd.read_excel(’/eos/project/m/mte/analysis/CPS/2017/Advancing_MTE_towards_HI_frontier/SPS_MTE_cycle_momentum_current.xlsx’, header = None, names = [‘timeM’, ‘momentum’, ‘timeI’, ‘current’])
momentum = SPS_cycle[[‘timeM’, ‘momentum’]].iloc[:-867]

to read in an Excel file. While such a command was working fine in the past, today I got the following error message

ImportErrorTraceback (most recent call last)
in ()
----> 1 SPS_cycle = pnd.read_excel(’/eos/project/m/mte/analysis/CPS/2017/Advancing_MTE_towards_HI_frontier/SPS_MTE_cycle_momentum_current.xlsx’, header = None, names = [‘timeM’, ‘momentum’, ‘timeI’, ‘current’])
2 momentum = SPS_cycle[[‘timeM’, ‘momentum’]].iloc[:-867]

/cvmfs/sft.cern.ch/lcg/views/LCG_95a/x86_64-centos7-gcc7-opt/lib/python2.7/site-packages/pandas/util/_decorators.pyc in wrapper(*args, **kwargs)
176 else:
177 kwargs[new_arg_name] = new_arg_value
–> 178 return func(*args, **kwargs)
179 return wrapper
180 return _deprecate_kwarg

/cvmfs/sft.cern.ch/lcg/views/LCG_95a/x86_64-centos7-gcc7-opt/lib/python2.7/site-packages/pandas/util/_decorators.pyc in wrapper(*args, **kwargs)
176 else:
177 kwargs[new_arg_name] = new_arg_value
–> 178 return func(*args, **kwargs)
179 return wrapper
180 return _deprecate_kwarg

/cvmfs/sft.cern.ch/lcg/views/LCG_95a/x86_64-centos7-gcc7-opt/lib/python2.7/site-packages/pandas/io/excel.pyc in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, **kwds)
305
306 if not isinstance(io, ExcelFile):
–> 307 io = ExcelFile(io, engine=engine)
308
309 return io.parse(

/cvmfs/sft.cern.ch/lcg/views/LCG_95a/x86_64-centos7-gcc7-opt/lib/python2.7/site-packages/pandas/io/excel.pyc in init(self, io, **kwds)
352 import xlrd
353 except ImportError:
–> 354 raise ImportError(err_msg)
355 else:
356 ver = tuple(map(int, xlrd.VERSION.split(".")[:2]))

ImportError: Install xlrd >= 0.9.0 for Excel support

I guess that the useful information is the last line of the message: how should I install xlrd under Swan?

Thanks a lot in advance for your help!

Dear Massimo,

Please go to SWAN, and above notebook click on “…” -> “Help”

In the HELP find:
Advanced setup -> Install packages in CERNBox

This will allow you to install any package you want.

We can probably include the xlrd in CVMFS releases - to be discussed @etejedor

@giovanno was this the solution, on something more is missing except that package?

Dear Piotr,

I tried to issue the command pip intall –user lxrd on a Swan terminal and the following is the error I got:

Could not find a version that satisfies the requirement lxrd (from versions: )

No matching distribution found for lxrd

You are using pip version 10.0.1, however version 19.1.1 is available.

You should consider upgrading via the ‘pip install --upgrade pip’ command.

Do you have any idea about a possible solution?

                                            Thanks a lot in advance. Cheers
                                                            Massimo

Ciao Massimo,
I imagine it is “xlrd” rather than “lxrd” :wink:
Andrea

Shame on me!
Thanks Andrea: I could install the package…

1 Like

Hello,

I want to install the package xlrd as well. The installation already worked:
requirement already satisfied: xlrd in /eos/home-j/juheinz/.local/lib/python3.7/site-packages (1.2.0)
But unfortunately I cannot import xlrd. I know, that in the help section of SWAN is explained, that one has to “add the local installation path to PYTHONPATH , by creating a bash startup script that configures that variable (don’t forget to call this startup script in the session configuration menu)”. But I don’t know how this works - can anyone help me here? Where am I supposed to execute this line: export PYTHONPATH=$CERNBOX_HOME/.local/lib/python3.5/site-packages:$PYTHONPATH and what I have to adjust in this code line?

Thanks a lot for your help!

Best regards,
Julia

Hello Julia,

Welcome to the SWAN community,
first all, I can see you have python3.5 in the line export PYTHONPATH=$CERNBOX_HOME/.local/lib/python3.5/site-packages:$PYTHONPATH
which stack are you using? because the python version can be different ex: LCG_97a is using python3.7

if you are using LCG_97a lets fix it by
export PYTHONPATH=$CERNBOX_HOME/.local/lib/python3.7/site-packages:$PYTHONPATH
and you can save this line in your file ~/.bashrc to make it permanent.

Cheers
Omar.

Hello Omar,

thank you very much, it work now.

Have a nice day!

Cheers
Julia

1 Like