I am trying to import StandardScalar from Sklearn, preprocessing but it keeps giving me an error.
This is the exact error:
ImportError Traceback (most recent call last)
<ipython-input-6-1f73df509116> in <module>
----> 1 from sklearn.preprocessing import StandardScalar
ImportError: cannot import name 'StandardScalar' from 'sklearn.preprocessing' (c:\users\abhijith rao\appdata\local\programs\python\python37-32\lib\site-packages\sklearn\preprocessing\__init__.py)
from sklearn.preprocessing import StandardScalar
Mistyping
StandardScalar -> StandardScaler
https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html
It is StandardScaler not StandardScalar
So,
Replace the line "from sklearn.preprocessing import StandardScalar" with
"from sklearn.preprocessing import StandardScaler"
Related
ImportError: Traceback (most recent call last):
File "/opt/conda/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
on3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcublas.so.10.0: cannot open shared object file: No such file or directory in the following code
import os
import tensorflow as tf
sess = tf.compat.v1.Session()
os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"]="1"
import tensorflow as tf
config = tf.compat.v1.ConfigProto()
config.gpu_options.allow_growth=True
import numpy as np
import pandas as pd
import pickle
from matplotlib import pyplot as plt
from PIL import Image
from IPython.display import Audio
from matplotlib.pyplot import imshow
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import OneHotEncoder
from sklearn.utils.class_weight import compute_class_weight
from tensorflow.contrib.keras import layers
from tensorflow.contrib.keras import models
from tensorflow.contrib.keras import layers
from tensorflow.contrib.keras import optimizers
from tensorflow.contrib.keras import callbacks
from tensorflow.contrib.keras import regularizers
from tensorflow.contrib.keras import models
%matplotlib inline
I am trying to apply scipy's Alexander Govern test:
import pandas as pd
import scipy.stats
df1 = pd.read_csv(r'Data1.tsv', sep='\t', encoding='utf-8')
df2 = pd.read_csv(r'Data2.tsv', sep='\t', encoding='utf-8')
from scipy.stats import alexandergovern
alexandergovernTest = alexandergovern(df1.iloc[2:,:135], df2.iloc[2:,:134])
print(alexandergovernTest)
I get the following error:
Traceback (most recent call last):
File "calculate_onewayANOVA.py", line 41, in <module>
from scipy.stats import alexandergovern
ImportError: cannot import name 'alexandergovern'
This error is resolved after upgrading to python3.8 in Ubuntu 20 and installing scipy==1.7.3, as indicated by #Nelewout and #WarrenWeckesser
I am trying to use the zipcodes package but was getting a ses error. Here is a brief snippt of my code.
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set()
import geopandas as gpd
import requests
import zipfile
import io
import os
import pyproj
from shapely.ops import transform
from functools import partial
import json
from uszipcode import SearchEngine
search = SearchEngine(simple_zipcode=True)
I am getting the following error
Exception ignored in: <function SearchEngine.__del__ at 0x7fcd6087eca0>
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/uszipcode/search.py", line 195, in __del__
if self.ses:
AttributeError: 'SearchEngine' object has no attribute 'ses'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-35-325ac6f8df7d> in <module>
----> 1 search = SearchEngine(simple_zipcode=True)
2 search.ses.scalar(SimpleZipcode)
TypeError: __init__() got an unexpected keyword argument 'simple_zipcode'
Any pointers?
When I import pandas in jupyter library the following is generated.
AttributeError Traceback (most recent call last)
<ipython-input-24-f869c0f42cc0> in <module>
----> 1 import pandas as pd
2 import numpy as np
3 get_ipython().run_line_magic('matplotlib', 'inline')
C:\ProgramData\Anaconda3\lib\site-packages\pandas\__init__.py in <module>
24
25 try:
---> 26 from pandas._libs import (hashtable as _hashtable,
27 lib as _lib,
28 tslib as _tslib)
pandas\_libs\hashtable_class_helper.pxi in init pandas._libs.hashtable()
AttributeError: type object 'pandas._libs.hashtable.HashTable' has no attribute '__reduce_cython__'
Can you help me in figuring out the problem? Thanks
Use pd at the place of pandas in your code. If you still get error, then write your code also in the question.
This question already has answers here:
Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError
(2 answers)
Closed 4 years ago.
I'm working with a project and somewhere down the line my I have to uninstall and reinstall numpy to fix a problem, but then this happened
Traceback (most recent call last):
File "ori2.py", line 3, in <module>
import numpy as np
File "/home/tsoi/Documents/environments/testvenv/my_venv/lib/python3.6/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/home/tsoi/Documents/environments/testvenv/my_venv/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/tsoi/Documents/environments/testvenv/my_venv/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/tsoi/Documents/environments/testvenv/my_venv/lib/python3.6/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/tsoi/Documents/environments/testvenv/my_venv/lib/python3.6/site-packages/numpy/core/__init__.py", line 38, in <module>
from . import numeric
File "/home/tsoi/Documents/environments/testvenv/my_venv/lib/python3.6/site-packages/numpy/core/numeric.py", line 43, in <module>
import pickle
File "/home/tsoi/Documents/environments/testvenv/Traffic-rec/pickle.py", line 1
from ~/Documents/environments/testvenv/my_venv/lib/python3.6/site-packages/numpy import numpy as np
^
SyntaxError: invalid syntax
I have also tried
import sys
sys.path.append('~/Documents/environments/testvenv/my_venv/lib/python3.6/site-packages/numpy')
when importing numpy but the same error occured, This hasn't happened before and it's been annoying for me. This is the part of my code that I think is relevant to this problem:
from __future__ import print_function
#from comet_ml import Experiment
import numpy as np
import tensorflow as tf
import keras
from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
from keras.datasets import fashion_mnist
from keras.models import Model
from keras.layers import Input, Dense
from keras.models import load_model
import cv2
import os
import glob
from os import path
import random
UPDATE:
Yeah you right user2357112
numpy is importing your file '/home/tsoi/Documents/environments/testvenv/Traffic-rec/pickle.py' instead of the pickle module, delete the file or rename it, then the problem should be fixed.