ModuleNotFoundError: No module named 'dataclasses'

After all I think all what was needed was

conda env create -n fastai -f environment-cpu.yml

OS - Windows 10
conda version : 4.5.11
conda-build version : 3.15.1
python version : 3.6.6

followed below mentioned steps -

  1. git clone https://github.com/fastai/fastai.git
  2. cd fastai
  3. conda env update -f environment-cpu.yml
  4. resolved few pip install error by installing from whl file
  5. activate fastai-cpu
  6. jupyter nbextension enable --py widgetsnbextension --sys-prefix
  7. cd courses\ml1
    del fastai
    mklink /d fastai …\fastai
    cd …

given the steps above.

What are you installing in step 4?

Why the relinking in step 4? The link must point to ../../old/fastai so you are using fastai 0.7 and not 1.0.

1 Like

yes, so as @aberres writes, you are definitely linking the wrong folder, so this is why you are using v1 of fastai and getting the dataclasses error and other problems. so remove those links and link the correct “old” folder. if that does not help then within that environment do the pip install of 0.7.0 like stated above.

@stas has just opened a new thread for v0.7 installation issues (which are probably plenty, because old posts all make you do stuff that doesn‘t work now anymore, such as your mklink stuff above). This explanation should get you there:

Thank you @marcmuc & @aberres for the help.

No I have resolved the error for dataclasses pointing to old/fastai folder , however now I am getting below mentioned error.

ModuleNotFoundError: No module named ‘bcolz’

in the fastai-cpu env did the installation of bcolz (conda install -c anaconda bcolz) but still getting the same error.

Any idea about this one ?

Not sure, but always search the forums first. You are not alone with this problem, look for solutions here :slight_smile::

2 Likes

Thank you , i did try those steps , however running below command worked now for me :slight_smile:

conda install nb_conda

Thank you again @marcmuc and @aberres for continuous support to resolve the issues.

in my case link is pointing to ../../old/fastai but still i get this error “No module named dataclasses”

OS : Win 10
conda 4.5.11
Python 3.6.7

Hi

I successfully went through the Server Setup for AWS EC2, after starting an instance and running a notebook I get 'ModuleNotFoundError: No module named ‘dataclasses’ when running the following code.

from fastai.vision import *

Any help welcome

Thanks

Jonathan

1 Like

pip install dataclasses

worked for me!

1 Like

conda install dataclasses also installed the right package for me. this allows me to run the import in python 3.6

2 Likes

ty, this helped

What does the (relevant bit of the) setup script do? I see " dataclasses ; python_version<‘3.7’" on line 87, within the definition of dep_group. What does it do?

I have also found Jeremy’s remark to this question that python3.6 can be used with fastai v1 as long as dataclasses is installed (via pip). How can that be? Is dataclasses simply a new package that comes shipped with 3.7 but not with 3.6, and can simply be installed separately?

The setup script makes the availability of the module “dataclasses” mandatory for python versions lower than 3.7, but only for those, since it is included in python3.7 by default.

Python 3.7 has a number of improvements/additions vs. Python 3.6, but the only thing out of those that fastai uses is dataclasses. So 3.7 is required because fastai makes use of dataclasses. In Python it is customary that at least some additions to new python versions are also made available as so called “backports”. So if you want to make use of the dataclasses feature of the language, but for some reason cannot or do not want to upgrade your base python version (which happens often in production settings), you can use these backports to import the feature into an older version.

So, you can use python 3.6 but then you have to manually add the backport for dataclasses to the language, which you do by installing it via pip install dataclasses.

1 Like

Hello,
I encountered the same error. Have you solved it? Thanks.

Hi, hope the above answers were useful and you were able to resolve the issue. In case it still persists, I ran into this error (randomly?) today (after several weeks of everything running fine). Based on the forum discussions, I tried the steps below:

**Step / Solution 1:**
ModuleNotFoundError: No module named 'dataclasses'
conda install dataclasses

**Step / Solution 2:**
ModuleNotFoundError: No module named 'fastprogress'
conda install -c fastai fastprogress

**Step / Solution 3:**
ImportError: cannot import name 'as_tensor'
ln -s ~/fastai/courses/ml1/fastai fastai`

I thought problems would end after step 1, but then additional issues came up. I remember the instructor mentioned something about symlinks (or shortcuts in Windows) the last code line does that.

(For now) what worked for me is below:

cd <working directory for your notebook>
ln -s <source> <link>
ln -s ~/fastai/courses/ml1/fastai fastai`

Thanks for your feedback and support.

I got these errors and followed these steps until the last one which is a unix specific code. Where do I write the ln code? It shows it’s unrecognized both in cmd and Anaconda Prompt

1 Like

Hi, I think there was a type on the last command, it should be (without the apostrophe at the end)
ln -s ~/fastai/courses/ml1/fastai fastai

You can type the ‘ln’ command on the Ubuntu terminal or Jupyter notebook:

On the terminal:
ln --version

In the notebook:
!ln --version

The ln seems to be a standard Unix command. If it persists, can you paste the exact error you are getting?

1 Like