This is my code:-
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pylab import rcParams
rcParams['figure.figsize']=20,10
from keras import Sequential
from keras import LSTM,Dropout,Dense
from sklearn.preprocessing import MinMaxScaler
df=pd.read_csv("/Users/apple/Desktop/NSE-Tata-Global-Beverages-Limited.csv")
df.head()
df["Date"]=pd.to_datetime(df.Date,format="%Y-%m-%d")
df.index=df['Date']
plt.figure(figsize=(16,8))
plt.plot(df["Close"],label='Close Price history')
It shows error as follows:-
Users/apple/PycharmProjects/pythonProject4/venv/bin/python /Users/apple/PycharmProjects/pythonProject4/main.py
Traceback (most recent call last):
File "/Users/apple/PycharmProjects/pythonProject4/main.py", line 9, in <module>
from keras import Sequential
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/keras/__init__.py", line 21, in <module>
from keras import models
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/keras/models/__init__.py", line 18, in <module>
from keras.engine.functional import Functional
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/keras/engine/functional.py", line 24, in <module>
import tensorflow.compat.v2 as tf
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/__init__.py", line 75, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/core/framework/node_def_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site- packages/tensorflow/core/framework/resource_handle_pb2.py", line 36, in <module>
_descriptor.FieldDescriptor(
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site- packages/google/protobuf/descriptor.py", line 560, in __new__
_message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure- Python parsing and will be much slower).
More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates
Process finished with exit code 1
I have installed both "keras" and "tensorflow both through the interpreter. Using pycharm 3. What is to be done? I have tried installling keras and tensorflow throguh the terminal as well. I have tried everything. Thank you for going through my question.
I did what Yevhen Kuzmovych told and now the error is:-
/Users/apple/PycharmProjects/pythonProject4/venv/bin/python /Users/apple/PycharmProjects/pythonProject4/main.py
/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/framework/dtypes.py:471: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint8 = np.dtype([("qint8", np.int8, 1)])
/Users/apple/PycharmProjects/pythonProject4/venv/lib /python3.11/site-packages/tensorflow/python/framework/dtypes.py:472: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/Users/apple/PycharmProjects/pythonProject4/venv/lib /python3.11/site-packages/tensorflow/python/framework/dtypes.py:473: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_qint16 = np.dtype([("qint16", np.int16, 1)])
/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/framework/dtypes.py:474: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/framework/dtypes.py:475: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
_ np_qint32 = np.dtype([("qint32", np.int32, 1)])
/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/framework/dtypes.py:490: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar. (This may have returned Python scalars in past versions.
(np.object, string),
Traceback (most recent call last):
File "/Users/apple/PycharmProjects/pythonProject4/main.py", line 9, in <module>
from keras import Sequential
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/keras/__init__.py", line 21, in <module>
from keras import models
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib /python3.11/site-packages/keras/models/__init__.py", line 18, in <module>
from keras.engine.functional import Functional
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/keras/engine/functional.py", line 24, in <module>
import tensorflow.compat.v2 as tf
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib /python3.11/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/__init__.py", line 84, in <module>
from tensorflow.python.framework.framework_lib import *
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/framework/framework_lib.py", line 73, in <module>
from tensorflow.python.framework.ops import Graph
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/framework/ops.py", line 39, in <module>
from tensorflow.python.framework import dtypes
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/tensorflow/python/framework/dtypes.py", line 490, in <module>
(np.object, string),
^^^^^^^^^
File "/Users/apple/PycharmProjects/pythonProject4/venv/lib/python3.11/site-packages/numpy/__init__.py", line 284, in __getattr__
raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'object'. Did you mean: 'object_'?
Process finished with exit code 1