Almenon / AREPL-vscode

Program python in real-time
MIT License
260 stars 29 forks source link

Problem with pandas -- core.config.OptionError #162

Closed chiboreache closed 5 years ago

chiboreache commented 5 years ago

Here crosspost from pandas repo, since I firstly post issue there, for whatever reason heh

Hi! It just poping up after a few seconds in interactive REPL

Code Sample


from arepldump import dump
# AREPL 1.0.6
# Name            : visual-studio-code-bin
# Version         : 1.30.2-1

import pandas as pd
df = pd.DataFrame()
print(df)

What I expected

Empty DataFrame Columns: [] Index: []

But what I got


Traceback (most recent call last):
  line 4, in <module>
  File "/usr/lib/python3.7/site-packages/pandas/core/frame.py", line 348, in __init__
    mgr = self._init_dict(data, index, columns, dtype=dtype)
  File "/usr/lib/python3.7/site-packages/pandas/core/frame.py", line 456, in _init_dict
    columns = data_names = Index(keys)
  File "/usr/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 264, in __new__
    from .range import RangeIndex
  File "/usr/lib/python3.7/site-packages/pandas/core/indexes/range.py", line 20, in <module>
    from pandas.core.indexes.base import Index, _index_shared_docs
  File "/usr/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 17, in <module>
    from pandas.core.arrays import ExtensionArray
  File "/usr/lib/python3.7/site-packages/pandas/core/arrays/__init__.py", line 2, in <module>
    from .categorical import Categorical  # noqa
  File "/usr/lib/python3.7/site-packages/pandas/core/arrays/categorical.py", line 35, in <module>
    from pandas.core.base import (PandasObject,
  File "/usr/lib/python3.7/site-packages/pandas/core/base.py", line 23, in <module>
    import pandas.core.nanops as nanops
  File "/usr/lib/python3.7/site-packages/pandas/core/nanops.py", line 55, in <module>
    set_use_bottleneck(get_option('compute.use_bottleneck'))
  File "/usr/lib/python3.7/site-packages/pandas/core/config.py", line 227, in __call__
    return self.__func__(*args, **kwds)
  File "/usr/lib/python3.7/site-packages/pandas/core/config.py", line 97, in _get_option
    key = _get_single_key(pat, silent)
  File "/usr/lib/python3.7/site-packages/pandas/core/config.py", line 83, in _get_single_key
    raise OptionError('No such keys(s): {pat!r}'.format(pat=pat))
pandas.core.config.OptionError: "No such keys(s): 'compute.use_bottleneck'"

Print Output:
{}
0 ms

Output of pd.show_versions()

``` INSTALLED VERSIONS ------------------ commit: None python: 3.7.2.final.0 python-bits: 64 OS: Linux OS-release: 4.20.1-arch1-1-ARCH machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8 pandas: 0.23.4 pytest: None pip: 18.1 setuptools: 40.6.3 Cython: 0.29.2 numpy: 1.15.4 scipy: None pyarrow: None xarray: None IPython: 7.1.1 sphinx: 1.8.3 patsy: None dateutil: 2.7.5 pytz: 2018.9 blosc: None bottleneck: None tables: None numexpr: None feather: None matplotlib: None openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: 4.7.0 html5lib: 1.0.1 sqlalchemy: 1.2.15 pymysql: None psycopg2: 2.7.6.1 (dt dec pq3 ext lo64) jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None None ```
Almenon commented 5 years ago

Confirmed bug with version .23.4 - it works in console but not in arepl.

I'll have to look into this.

Almenon commented 5 years ago

I think It's a bug with the jsonpickle library I use but I'm having difficulty replicating it with a minimal example. I will look more into this later when I have better internet

Almenon commented 5 years ago

So now for some reason on the first run of the code you provided it works fine, but on the second run it gets a different error:

Traceback (most recent call last):
  line 7, in <module>
  File "C:\Users\anon\AppData\Roaming\Python\Python36\site-packages\pandas\core\frame.py", line 391, in __init__
    mgr = init_dict(data, index, columns, dtype=dtype)
  File "C:\Users\anon\AppData\Roaming\Python\Python36\site-packages\pandas\core\internals\construction.py", line 209, in init_dict
    columns = data_names = Index(keys)
  File "C:\Users\anon\AppData\Roaming\Python\Python36\site-packages\pandas\core\indexes\base.py", line 266, in __new__
    from .range import RangeIndex
SystemError: Parent module 'pandas.core.indexes' not loaded, cannot perform relative import

I unload user modules after each arepl run in case the user has changed them (in which case they would need to be reloaded), so I guessed that might the problem here. I added pandas.core.indexes into moduleLogic.py and the error went away ...... to be replaced by the error you originally reported.

So now I'm suspicous of the module unloading logic. I added a print to see what modules got unloaded and omg so many modules no wonder things were breaking.

pandas.util._exceptions
pandas.core.arrays.interval
pandas.core.window
pandas.plotting._misc
pandas.core.computation.eval
pytz.exceptions
dateutil.tz.win
pandas.core.indexes.range
pytz.tzinfo
pandas.plotting._style
pandas.core.missing
pandas.core.dtypes.concat
pandas.core.computation.ops
matplotlib.compat.subprocess
pandas.core.reshape.api
typing.io
pandas.core.computation.scope
pandas.core.computation.common
pandas.core.dtypes.common
pandas._libs.lib
pandas.compat.chainmap
matplotlib.dates
pandas.core.accessor
pandas.core.reshape.tile
pandas.core.generic
pandas.core.reshape.merge
pandas.core.arrays.datetimes
pandas.api.types
pandas.core.internals.arrays
pandas.io.json.normalize
pandas._libs.tslib
pandas.io.feather_format
pandas.core.frame
matplotlib._path
pandas.io.msgpack._version
dateutil.easter
pandas.core.arrays.numpy_
pandas.tseries.offsets
dateutil.tz
pandas.util._decorators
pandas.compat.numpy
pandas._libs
pandas.util._print_versions
pandas._libs.writers
pandas.core.sparse
pandas.compat
pandas.core.indexes.accessors
pandas.core.computation.engines
matplotlib.ticker
dateutil.rrule
pandas.core.indexes.numeric
pandas._libs.hashtable
pandas.io.date_converters
pandas.core.indexes.datetimelike
pandas.io.parsers
pandas.util
pandas.core.sparse.frame
pandas.api
pandas.io.formats.console
pandas.util._validators
pandas.core.index
pandas._libs.interval
ctypes.wintypes
pandas.io.sas
pandas.io.sas.sasreader
pandas.core.internals.construction
pandas.util._doctools
pandas.core.config
pandas.io.msgpack._unpacker
pandas.core.dtypes
pandas.core.groupby
pandas._libs.tslibs.timestamps
pandas.core.series
six.moves.urllib.request
pandas._libs.tslibs.resolution
pandas._libs.testing
pandas.core.strings
pandas.io.msgpack.exceptions
dateutil.parser
pandas._libs.skiplist
pandas.core.api
pandas.core.dtypes.missing
pandas.io.formats
pandas.plotting._compat
pandas.io.excel
pandas.core.dtypes.generic
pandas.arrays
pandas._libs.reduction
pandas.io.json
pandas.core.dtypes.api
pandas._libs.sparse
six.moves.urllib
pandas._libs.tslibs.parsing
pandas.core.reshape.concat
pandas.core.indexing
pandas.util._tester
pandas.core.internals
pandas.io.formats.terminal
pandas.plotting._core
pandas.io.api
pandas._libs.tslibs.offsets
pandas.core.indexes.datetimes
pandas._libs.tslibs.nattype
pandas.core.dtypes.dtypes
pandas._libs.internals
pandas.io.msgpack._packer
pandas.core.sorting
pandas._libs.tslibs.timezones
pandas._libs.join
pandas.io.pytables
pandas.io.html
pandas.core.reshape.util
pandas.io.clipboards
pandas.plotting._tools
pandas.core.computation.pytables
pandas._libs.indexing
pandas.core.dtypes.inference
pandas._version
pandas.core.computation.align
dateutil.tz.tz
six.moves
pandas.io.stata
pandas.io.parquet
matplotlib.cbook
pandas.core.internals.blocks
pandas.core.groupby.grouper
pandas.core.computation.api
pandas.core.tools
matplotlib._version
pandas.core.arrays.period
pandas.io.formats.printing
pandas.core.tools.timedeltas
pandas._libs.tslibs.np_datetime
dateutil.tz._common
pandas.plotting._converter
pandas.compat.numpy.function
_cython_0_29_3
pandas.core.reshape.pivot
pandas._libs.algos
matplotlib._color_data
pandas._libs.properties
pandas._libs.tslibs.strptime
pandas.core
matplotlib.path
pandas.core.util.hashing
pandas.io.json.table_schema
pandas.io.common
pandas.io.packers
pandas.core.tools.datetimes
pandas.tseries
pandas.core.arrays._ranges
matplotlib.rcsetup
pandas.core.arrays.categorical
typing.re
pandas.io.sql
pandas.errors
pandas.core.arrays.integer
pandas.core.reshape.melt
pandas.core.indexes.timedeltas
matplotlib.transforms
pandas.io.gbq
pandas._libs.hashing
pandas.core.arrays.base
pandas.core.ops
pandas.core.arrays.array_
pandas.core.arrays.datetimelike
pandas.core.indexes.multi
pandas.core.computation.expr
pandas.core.groupby.ops
pandas.compat.pickle_compat
pandas._libs.tslibs.period
pandas._libs.json
pandas.core.tools.numeric
pandas._libs.tslibs.frequencies
matplotlib.fontconfig_pattern
pandas._libs.tslibs.fields
pandas.core.groupby.groupby
pandas.core.groupby.generic
pandas._libs.tslibs
pandas._libs.reshape
pandas.core.sparse.api
pandas.tseries.api
pandas.core.arrays.timedeltas
pandas.tseries.frequencies
pandas.io
pandas.io.pickle
pandas.core.nanops
pandas.core.internals.concat
matplotlib.units
pandas.core.reshape.reshape
pandas._libs.ops
pandas.core.config_init
pandas.io.formats.format
pandas.util._move
pandas.core.arrays.sparse
pandas._libs.window
pandas.core.groupby.base
pandas.core.computation
pandas.core.indexes.interval
pandas.core.util
pandas.core.indexes.base
pandas.core.base
pythonEvaluator
pandas._libs.index
pandas.util.testing
dateutil._common
pandas.core.dtypes.base
pandas.core.panel
pandas.core.internals.managers
dateutil.relativedelta
pandas._libs.tslibs.ccalendar
pandas._libs.parsers
pandas.plotting
pandas.core.sparse.series
pandas._libs.missing
matplotlib.compat
pandas.core.indexes.period
matplotlib.colors
pandas.io.json.json
pandas.core.common
pandas._libs.tslibs.conversion
pandas.io.msgpack
pytz.lazy
pandas._libs.tslibs.timedeltas
pandas._libs.groupby
pandas.core.arrays
pandas.core.indexes.api
pandas.core.sparse.scipy_sparse
pandas.core.algorithms
pandas.core.reshape
pandas.core.dtypes.cast
pandas.core.indexes.frozen
pandas.api.extensions
pandas.core.indexes.category
dateutil
pytz.tzfile
pandas.testing

I'll have to revise my module reloading logic to fix this issue. Thanks for reporting it again!

chiboreache commented 5 years ago

just WOW

keep rocking mahn!

Almenon commented 5 years ago

Logic is fixed in backend. Expect a release w/ bugfix soon.

Almenon commented 5 years ago

I just released a new version of arepl. @chiboreache can you try your code out and see if it works please? If you have any any bug reports or suggestions on how I can improve pandas support feel free to create a issue.

chiboreache commented 5 years ago

@Almenon — Nice work mate! Thanks =)

Unfortunately, I have some small error popuping in my output, heh I'll create a new ticket ;)

Oh, and yeah, my pandas code work just right ¡)