Why i am getting the error fastai.structured is not a module?.
i have tried installing previous versions of fastai. but nothing helped.
from fastai.imports import *
from fastai.structured import *
#from pandas_summary import DataFrameSummary
from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
from IPython.display import display
from sklearn import metrics
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-17-35432a48f631> in <module>()
1 from fastai.imports import *
----> 2 from fastai.structured import *
3
4 #from pandas_summary import DataFrameSummary
5 from sklearn.ensemble import RandomForestRegressor, RandomForestClassifier
ModuleNotFoundError: No module named 'fastai.structured'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
That module is no longer included in fastai's default python packages. Your default setup commands for using fastai packages will no longer includes that module. You may need to download it from the GitHub master, save it to your working directory, and import from your working directory to your jupyter notebook.
Here's a note from the fastai forum:
The structured.py has been moved to folder “old” (in anticipation to fastai_v1).
https://github.com/fastai/fastai/blob/master/old/fastai/structured.py
--- Andrei Oct '18
When importing from your working directory:
from structured import *
This will replace:
from fastai.structured import *
The module’s name has been changed to “tabular”. So use “from fastai.tabular import *” instead.
see this >> https://forums.fast.ai/t/modulenotfounderror-no-module-named-fastai-structured/36904
Related
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?
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.
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.
here is my code to import some python libraries:
from radmc3dPy import *
from radmc3dPy.image import *
from radmc3dPy.analyze import *
from radmc3dPy.natconst import *
import matplotlib.pyplot as plt
import numpy as np
import os
from astropy.io import fits
import matplotlib.gridspec as gridspec
On running the cell, I receive the following error even after factory resetting the runtime:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-225d47afe30d> in <module>()
----> 1 from radmc3dPy import *
2 from radmc3dPy.image import *
3 from radmc3dPy.analyze import *
4 from radmc3dPy.natconst import *
5 import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'radmc3dPy'
you need to download and install the library before you can use it. I saw that there is a github for your package here: https://github.com/dullemond/radmc3d-2.0
in colab, you can install it with:
!git clone https://github.com/dullemond/radmc3d-2.0.git
%cd ./radmc3d-2.0/python/radmc3dPy/
!python setup.py install
%cd ~/../content
! and % are required.
The comand clones the desired directory from git, changes into the python directory, runs the setup of your package and changes your working directory back. Directly running the setup.py with the full path, did not work, hence changing the directory.
My issue is when trying to import the DCSBM model:
Code:
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import hyppo
from hyppo.time_series import _utils as _utils
from graspy.embed import AdjacencySpectralEmbed
from graspy.models import DCSBMEstimator
from graspy.models import EREstimator
from graspy.models import SBMEstimator
from graspy.models.sbm import _block_to_full, _get_block_indices
from graspy.simulations import er_np, sbm
Error:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-33-287386449480> in <module>()
8 from hyppo.time_series import _utils as _utils
9 from graspy.embed import AdjacencySpectralEmbed
---> 10 from graspy.models import DCSBMEstimator
11 from graspy.models import EREstimator
12 from graspy.models import SBMEstimator
2 frames
/usr/local/lib/python3.7/dist-packages/graspy/inference/latent_distribution_test.py in <module>()
26 from sklearn.metrics.pairwise import PAIRWISE_KERNEL_FUNCTIONS
27 from hyppo.ksample import KSample
---> 28 from hyppo._utils import gaussian
29
30 _VALID_DISTANCES = list(PAIRED_DISTANCES.keys())
ModuleNotFoundError: No module named 'hyppo._utils'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
I think hyppo._utils doesn't exist and has been replaced by hyppo.time_series and inside that folder there exists the required _utils package.
How do we fix this?
I was just trying to run the tutorial: https://docs.neurodata.io/notebooks/pedigo/graspologic/2020/09/24/latent_model_tutorial.html
Run on Google colab
This line
from hyppo.time_series import _utils as _utils was added from me trying to fix the issue, but doesn't work.
Looks like you're using an old version of the package - it's called "graspologic" now. If you pip install graspologic, from graspologic.models import DCSBMEstimator should work fine. Just replace everything in that code that says "graspy" with "graspologic".
we're happy to answer questions on github issues as well! (I'm one of the people who contributes to the package)
dtreeviz library, ImportError: cannot import name 'run'
I tried to follow this instruction on Github to install and import the dtreeviz library.
When I run the where dot and dot -V command both seem to work fine as you can see here Lines in Windows Terminal.
However when I try to import dtreeviz in Python (Anaconda, version 3.6.5) I get the following error:
from dtreeviz.trees import *
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-fd764fe550c7> in <module>()
1 from sklearn import tree
----> 2 from dtreeviz.trees import *
C:\Users\marcb\Anaconda3\lib\site-packages\dtreeviz\trees.py in <module>()
6 from pathlib import Path
7 from sklearn import tree
----> 8 from graphviz.backend import run, view
9 import matplotlib.pyplot as plt
10 from dtreeviz.shadow import *
ImportError: cannot import name 'run'
I hope that someone can help me as I want to use this library to visualize single trees in Python and this library offers much more features than the original graphviz package.
Note: This is my first post on Stackoverflow, so feedback on this is also welcome.
I don't know if you are still looking for an awser, but i had exactly the same problem and fixed it this way:
In ~/.local/lib/python3.8/site-packages/dtreeviz/trees.py' i replaced the line
79: execute(' '.join(cmd), capture_output=True, check=True, quiet=False)
by
79: os.system(' '.join(cmd)).
I am receiving the following error in an iPython notebook:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-06ac68ebf148> in <module>()
5 import pandas as pd
6 import numpy as np
----> 7 from sklearn import neighbours
8
9 start_time = time.time()
ImportError: cannot import name neighbours
Whilst trying to run the following:
# Import required packages
import time
import pandas as pd
import numpy as np
from sklearn import neighbours
I get the same issue on the command line. My suspicions:
I believe my problem has something to do with my system path or environment variables. I've given this various attempts and have followed other answers (e.g. Python ImportError- what is wrong here?) but in vain thus far. My current system Path variable includes the location of my python script; the environment PATH variable includes the location of the Anaconda libraries: "...\Anaconda2\Library\bin;". Does this appear correct?
Many solutions refer to circular dependencies, which I do not believe I have in the one module.
Other solutions are to do with the name of the script. Mine is named 'my_solution', so I do not believe this is an issue.
My sklearn folder can be found in \AppData\Local\Continuum\Anaconda2\Lib\site-packages\sklearn
I have recently uninstalled a standalone Python application. I have also reinstalled Anadonda and the scikit-learn, numpy and scipy packages multiple times.
I am using Python 2.7.11 through Anaconda 2.5.0 on Windows 7.
You want the American spelling of neighbours, i.e.
from sklearn import neighbors