1

I am trying to import two hdf5 files. dataFolder contains the file path. I am using a conda venvvirtual environment in VScode. I have installed the same software via the exact same way on another computer and it works fine. The code I am trying to use is:

trainData = pd.read_hdf(dataFolder+"dftrain.h5").values
trainData = np.array(trainData)

validData = pd.read_hdf(dataFolder+"dfvalid.h5").values
validData = np.array(validData)

nTrain = trainData.shape[0]
nValid = validData.shape[0]

I have tried to conda install pytables and it shows it is already installed. (Checked also with conda list and its there: pytables 3.6.1 py38ha5be198_0

PS D:\###\####\MLPM> conda install pytables
Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

I get the following traceback, stating that I have to install tables at the end:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-5-421c5198a2e1> in <module>
      1 dataFolder = "D:/Master/ETH Spring2021/MLPM/"
      2 #C:/Users/gfrusque/Spyder_DataExploration/
----> 3 trainData = pd.read_hdf(dataFolder+"dftrain.h5").values
      4 trainData = np.array(trainData)
      5 

~\anaconda3\envs\myenv\lib\site-packages\pandas\io\pytables.py in read_hdf(path_or_buf, key, mode, errors, where, start, stop, columns, iterator, chunksize, **kwargs)
    397             raise FileNotFoundError(f"File {path_or_buf} does not exist")
    398 
--> 399         store = HDFStore(path_or_buf, mode=mode, errors=errors, **kwargs)
    400         # can't auto open/close if we are using an iterator
    401         # so delegate to the iterator

~\anaconda3\envs\myenv\lib\site-packages\pandas\io\pytables.py in __init__(self, path, mode, complevel, complib, fletcher32, **kwargs)
    540             raise ValueError("format is not a defined argument for HDFStore")
    541 
--> 542         tables = import_optional_dependency("tables")
    543 
    544         if complib is not None and complib not in tables.filters.all_complibs:

~\anaconda3\envs\myenv\lib\site-packages\pandas\compat\_optional.py in import_optional_dependency(name, extra, raise_on_missing, on_version)
    107     except ImportError:
    108         if raise_on_missing:
--> 109             raise ImportError(msg) from None
    110         else:
    111             return None

ImportError: Missing optional dependency 'tables'.  Use pip or conda to install tables.

I have tried these: https://anaconda.org/ska/tables Missing optional dependency 'tables'. In pandas to_hdf ImportError HDFStore requires PyTables No module named tables

conda 4.9.2 Another weird thing is this:

PS D:\Master\ETH Spring2021\MLPM> python --version
Python 3.8.5

while the version indicated on the bottom right is Python 3.7.10 64-bit ('myenv':conda)

Kalio
  • 71
  • 1
  • 3

0 Answers0