1

I am using the module ydata_synthetic (github link) for generating synthetic timeseries datasets. After installing the package, I ran the following commands:

from os import path
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

from ydata_synthetic.synthesizers import ModelParameters
from ydata_synthetic.preprocessing.timeseries import processed_stock
from ydata_synthetic.synthesizers.timeseries import TimeGAN

I am receiving the following error:

ImportError                               Traceback (most recent call last)
<ipython-input-11-9f2f25e511c0> in <module>
      4 import matplotlib.pyplot as plt
      5 
----> 6 from ydata_synthetic.synthesizers import ModelParameters
      7 from ydata_synthetic.preprocessing.timeseries import processed_stock
      8 from ydata_synthetic.synthesizers.timeseries import TimeGAN

ImportError: cannot import name 'ModelParameters'

How can I solve this error?

Sam1729
  • 31
  • 2
  • Are you sure, that you installed the correct package using this command `pip install ydata-synthetic`? Do you have multiple environments or python interpreter installed? – Noltibus Apr 13 '22 at 06:01
  • I used the above mentioned pip command. However I had to create a new environment to use this package since I have default Python version of 3.9 (which falls outside the version range for installation). The new virtual environment I am using has python version of 3.6 and I successfully installed the ```ydata_synthetic``` package. – Sam1729 Apr 13 '22 at 06:05

2 Answers2

0

Please make sure, that the virtual environment, where you installed the package is the same one where you try to execute your code. In case of venv or anaconda, you need to explicitly activate it in the console/terminal, then use pip to install your package and then also use that activated environment to execute your python script. If you are using an IDE, you need to set your IDE python interpreter to that specific new environment you created and installed the packe in.

Noltibus
  • 1,300
  • 3
  • 12
  • 34
  • I'm using anaconda and running the script on jupyter notebook in that virtual environment itself – Sam1729 Apr 13 '22 at 07:16
  • Please check if the environment in the Jupyter notebook is the one where you installed the package into using this: https://stackoverflow.com/a/39070588/6299772 – Noltibus Apr 13 '22 at 08:51
0

Unexpected solution I found:

Use Python 3.7 (not 3.6, or 3.8+).

It seems like much of the code requires features that were new to 3.7 (eg namedtuple with default values), but the codebase has not yet been adjusted to run with python 3.8 or later.

Mich55
  • 93
  • 13