I am starting with a ML model and importing libraries. Every library is working fine except MGLEARN which throws error:
ModuleNotFoundError: No module named 'MGLEARN'.
I didn't pip install anything.
import sys
print("Python version: {}".format(sys.version))
import matplotlib
import matplotlib.pyplot as plt
import pandas as pd
print("pandas version: {}".format(pd.__version__))
import matplotlib
print("matplotlib version: {}".format(matplotlib.__version__))
import numpy as np
print("NumPy version: {}".format(np.__version__))
import scipy as sp
print("SciPy version: {}".format(sp.__version__))
import IPython
print("IPython version: {}".format(IPython.__version__))
import sklearn
print("scikit-learn version: {}".format(sklearn.__version__))
import mglearn
The output I get
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 17
15 import sklearn
16 print("scikit-learn version: {}".format(sklearn.__version__))
---> 17 import MGLEARN
ModuleNotFoundError: No module named 'MGLEARN'
Pip install anything gives error
!pip install mglearn
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[7], line 1
----> 1 get_ipython().system('pip install mglearn')
File /lib/python3.10/site-packages/IPython/core/interactiveshell.py:2542, in InteractiveShell.system_piped(self, cmd)
2537 raise OSError("Background processes not supported.")
2539 # we explicitly do NOT return the subprocess status code, because
2540 # a non-None value would trigger :func:`sys.displayhook` calls.
2541 # Instead, we store the exit_code in user_ns.
-> 2542 self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1))
File /lib/python3.10/site-packages/IPython/utils/_process_posix.py:129, in ProcessHandler.system(self, cmd)
125 enc = DEFAULT_ENCODING
127 # Patterns to match on the output, for pexpect. We read input and
128 # allow either a short timeout or EOF
--> 129 patterns = [pexpect.TIMEOUT, pexpect.EOF]
130 # the index of the EOF pattern in the list.
131 # even though we know it's 1, this call means we don't have to worry if
132 # we change the above list, and forget to change this value:
133 EOF_index = patterns.index(pexpect.EOF)
AttributeError: module 'pexpect' has no attribute 'TIMEOUT'
Related
I am trying to read a .sav file. For this, I have installed pyreadstat using
conda install -c conda-forge pyreadstat
but when I run the following line of code (before even getting to reading the file):
import pyreadstat
I get this error: "AttributeError: module 'pandas' has no attribute 'Float64Dtype' ".
Any ideas on how to solve it?
Complete error is as follows
AttributeError Traceback (most recent call last)
Input In [3], in <cell line: 2>()
1 import pandas
----> 2 import pyreadstat
File ~\anaconda3\envs\dhdsblend2021\lib\site-packages\pyreadstat\__init__.py:17, in <module>
1 # #############################################################################
2 # Copyright 2018 Hoffmann-La Roche
3 #
(...)
14 # limitations under the License.
15 # #############################################################################
---> 17 from .pyreadstat import read_sas7bdat, read_xport, read_dta, read_sav, read_por, read_sas7bcat
18 from .pyreadstat import write_sav, write_dta, write_xport, write_por
19 from .pyreadstat import set_value_labels, set_catalog_to_sas
File pyreadstat\pyreadstat.pyx:1, in init pyreadstat.pyreadstat()
File pyreadstat\_readstat_writer.pyx:42, in init pyreadstat._readstat_writer()
File ~\anaconda3\envs\dhdsblend2021\lib\site-packages\pandas\__init__.py:258, in __getattr__(name)
254 from pandas.core.arrays.sparse import SparseArray as _SparseArray
256 return _SparseArray
--> 258 raise AttributeError(f"module 'pandas' has no attribute '{name}'")
Pyreadstat requires Pandas 1.2.0 at the very minimum. Please try updating pandas to a newer version.
Hello I have been trying to learn Reinforcement Learning and I am trying to import the following libraries:
import os
import gym
from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import DummyVecEnv
from stable_baselines3.common.evaluation import evaluate_policy
However, I am getting the following error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-5bf8ebd8fe1a> in <module>
1 import os
----> 2 import gym
3 from stable_baselines3 import PPO
4 from stable_baselines3.common.vec_env import DummyVecEnv
5 from stable_baselines3.common.evaluation import evaluate_policy
~\Anaconda3\lib\site-packages\gym\__init__.py in <module>
14 from gym import logger
15 from gym import vector
---> 16 from gym import wrappers
17
18 __all__ = ["Env", "Space", "Wrapper", "make", "spec", "register"]
~\Anaconda3\lib\site-packages\gym\wrappers\__init__.py in <module>
3 from gym.wrappers.time_limit import TimeLimit
4 from gym.wrappers.filter_observation import FilterObservation
----> 5 from gym.wrappers.atari_preprocessing import AtariPreprocessing
6 from gym.wrappers.time_aware_observation import TimeAwareObservation
7 from gym.wrappers.rescale_action import RescaleAction
~\Anaconda3\lib\site-packages\gym\wrappers\atari_preprocessing.py in <module>
5
6 try:
----> 7 import cv2
8 except ImportError:
9 cv2 = None
~\Anaconda3\lib\site-packages\cv2\__init__.py in <module>
179
180
--> 181 bootstrap()
~\Anaconda3\lib\site-packages\cv2\__init__.py in bootstrap()
173
174 for submodule in __collect_extra_submodules(DEBUG):
--> 175 if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
176 if DEBUG: print("Extra Python code for", submodule, "is loaded")
177
~\Anaconda3\lib\site-packages\cv2\__init__.py in __load_extra_py_code_for_module(base, name, enable_debug_print)
26 native_module = sys.modules.pop(module_name, None)
27 try:
---> 28 py_module = importlib.import_module(module_name)
29 except ImportError as err:
30 if enable_debug_print:
~\Anaconda3\lib\importlib\__init__.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
~\Anaconda3\lib\site-packages\cv2\gapi\__init__.py in <module>
288
289
--> 290 cv.gapi.wip.GStreamerPipeline = cv.gapi_wip_gst_GStreamerPipeline
AttributeError: module 'cv2' has no attribute 'gapi_wip_gst_GStreamerPipeline'
I have tried searching on the stackoverflow and one of the recommendations was to update opencv that I did using the following command:
!pip install opencv-python==4.6.0.66
However, This did not work and the system told me it is already pre-installed.
Requirement already satisfied: opencv-python==4.6.0.66 in c:\users\mashood\anaconda3\lib\site-packages (4.6.0.66)
Requirement already satisfied: numpy>=1.14.5 in c:\users\mashood\anaconda3\lib\site-packages (from opencv-python==4.6.0.66) (1.19.5)
I need to know what I am doing wrong! Thanks!
The first cell of my jupyter notebook contains the libraries I want to import. For some reason when I run it receive the ImportError: cannot import name randbits. I have never seen this import error before and have already tried restarting the kernel and confirmed that all libraries were installed correctly. As anyone seen this before and know what to do about this error?
import numpy as np
import pandas as pd
import requests
import xlsxwriter
import math
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import numpy as np
2 import pandas as pd
3 import requests
File C:\pyver\py3.10.5\lib\site-packages\numpy\__init__.py:151, in <module>
149 from . import fft
150 from . import polynomial
--> 151 from . import random
152 from . import ctypeslib
153 from . import ma
File C:\pyver\py3.10.5\lib\site-packages\numpy\random\__init__.py:180, in <module>
126 __all__ = [
127 'beta',
128 'binomial',
(...)
176 'zipf',
177 ]
179 # add these for module-freeze analysis (like PyInstaller)
--> 180 from . import _pickle
181 from . import _common
182 from . import _bounded_integers
File C:\pyver\py3.10.5\lib\site-packages\numpy\random\_pickle.py:1, in <module>
----> 1 from .mtrand import RandomState
2 from ._philox import Philox
3 from ._pcg64 import PCG64, PCG64DXSM
File mtrand.pyx:1, in init numpy.random.mtrand()
File bit_generator.pyx:38, in init numpy.random.bit_generator()
ImportError: cannot import name randbits
I have been having the same issue all day. Finally figured out what solved my problem. Somehow anaconda3/Lib/secrets.py got overwritten. Numpy relies on files in this directory called random.py and secrets.py so if you have files with those names numpy will not load.
-I renamed my incorrect secrets.py file
-Found the secrets.py source code and recreated the file. Solved my issue. Hope it helps. The links below were the most beneficial for me.
People having similar issues with numpy:
https://github.com/numpy/numpy/issues/14860
Source code for secrets.py:
https://github.com/python/cpython/blob/3.7/Lib/secrets.py
My code
!pip install stldecompose
from stldecompose import decompose
Error Msg
ImportError Traceback (most recent call last)
in
2 # Install the library via PIP
3 get_ipython().system('pip install stldecompose')
----> 4 from stldecompose import decompose, forecast
~/opt/anaconda3/lib/python3.7/site-packages/stldecompose/init.py in
----> 1 from .stl import decompose, forecast
~/opt/anaconda3/lib/python3.7/site-packages/stldecompose/stl.py in
3 from pandas.core.nanops import nanmean as pd_nanmean
4 from statsmodels.tsa.seasonal import DecomposeResult
----> 5 from statsmodels.tsa.filters._utils import _maybe_get_pandas_wrapper_freq
6 import statsmodels.api as sm
7
ImportError: cannot import name '_maybe_get_pandas_wrapper_freq' from 'statsmodels.tsa.filters._utils' (/Users/georgeng/opt/anaconda3/lib/python3.7/site-packages/statsmodels/tsa/filters/_utils.py)
You have two pathway to go about this:
If you are running statsmodels==0.11.0, statsmodels.tsa.filters._utils function was removed from the library.
Alternatively you may use statsmodels.tsa.seasonal.STL, which gives similar functionality. See its documentation:
https://www.statsmodels.org/stable/generated/statsmodels.tsa.seasonal.STL.html#statsmodels.tsa.seasonal.STL
Downgrade to pip install statsmodels==0.10.2
I am using anaconda to work with tensorflow and I think I did all the installs for object detection.
You can see the ipynb file here
https://github.com/tensorflow/models/blob/master/research/object_detection/object_detection_tutorial.ipynb
and the cell which got the error is the first code cell.
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
from distutils.version import StrictVersion
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops
if StrictVersion(tf.__version__) < StrictVersion('1.9.0'):
raise ImportError('Please upgrade your TensorFlow installation to v1.9.* or later!')
When I try to run sample called "object_detection_tutorial.ipynb" I got the following errors. What might be causing errors?
ValueError Traceback (most recent call last)
<ipython-input-1-1e9eee4e6961> in <module>
17 from object_detection.utils import ops as utils_ops
18
---> 19 if StrictVersion(tf.__version__) < StrictVersion('1.9.0'):
20 raise ImportError('Please upgrade your TensorFlow installation to v1.9.* or later!')
~/anaconda3/envs/tensorflow_cpu/lib/python3.7/distutils/version.py in __init__(self, vstring)
38 def __init__ (self, vstring=None):
39 if vstring:
---> 40 self.parse(vstring)
41
42 def __repr__ (self):
~/anaconda3/envs/tensorflow_cpu/lib/python3.7/distutils/version.py in parse(self, vstring)
135 match = self.version_re.match(vstring)
136 if not match:
--> 137 raise ValueError("invalid version number '%s'" % vstring)
138
139 (major, minor, patch, prerelease, prerelease_num) = \
ValueError: invalid version number '1.13.0-rc1'
It seems your TensorFlow is Pre-release version, and version.py cannot recognize that. So downgrade to TensorFlow 1.12.0 should solve your problem.
Ref: TensorFlow releases.
For me commenting out the lines
if StrictVersion(tf.__version__) < StrictVersion('1.9.0'):
raise ImportError('Please upgrade your TensorFlow installation to v1.9.*
or later!')
worked fine. The whole notebook ran.