I am trying to run a sample script where I use
import tensorflow as tf
def main():
if __name__ = '__main__':
tf.app.run(main = main)
that throws an error:
AttributeError: module 'tensorflow' has no attribute 'app'
but when i run it as:
from tensorflow.python.platform import app
it runs well.. the python version I am using is 3.6.1 and tensorflow version: 0.1.8
actuall even
print(tf.__version__)
is showing an attribute error..
AttributeError: module 'tensorflow' has no attribute '__version__'
As Mitiku pointed out.. there was a problem with the installation so i reinstalled it.. and it works now..
print( dir(tf)) -- this should show the list of packages under tensorflow..
My problem was running Tensorflow 1 script for version 2.
tf.app is moved to tf.compat.v1.app in version 2. There is a tool that helps to upgrade to version 2 automatically.
tf_upgrade_v2 --intree my_project/ --outtree my_project_v2/ --reportfile report.txt
I put it here in case somebody had same issue.
Related
I'm trying to balanced my data on jupyter-notebook, using SMOTE:
from imblearn import over_sampling
from imblearn.over_sampling import SMOTE
balanced = SMOTE()
x_balanced , y_balanced = balanced.fit_resample(X_train,y_train)
but I'm getting the following error on the first line -
AttributeError: module 'sklearn.metrics._dist_metrics' has no attribute 'DatasetsPair'
Why am I getting this error?
thanks.
Reinstall scikit learn to version 1.1.0. That should solve the problem
Had the same error while importing modules from skforecast package
from skforecast.model_selection import grid_search_forecaster
from skforecast.model_selection import backtesting_forecaster
Reinstalling scikit-learn to version 1.1.0 or 1.0.0 worked with additionally restarting the jupyter server.
I am trying to detect an object with Tensorflow as described here.
After runnig this command in the training part
python train.py --logtostderr --train_dir=training/ --pipeline_config_path=training/faster_rcnn_inception_v2_pets.config
I get the following error:
ImportError: cannot import name 'center_net_pb2' from 'object_detection.protos' (E:\Projects\Tensorflow_10Nov20\models-master\research\object_detection\protos\__init__.py)
Here is the relevant code
from object_detection.protos import center_net_pb2 as object__detection_dot_protos_dot_center__net__pb2
don't know what your protoc version is but try to upgrade it to atleast version 3.7.x, this might solve the problem.
System Info :
keras 2.3.1
pip 20.2.2
python 3.6.10
tensorflow 2.3.0
I am working on a siamese algorithm on keras tensorflow backend. I have imported keras backend as follow and it shows above attribute error. What could be the reason for that and how to avoid this issue?
import tensorflow.python.keras.backend as K
AttributeError: module 'tensorflow' has no attribute 'python'
It means that within the module 'tensorflow', no attribute named 'python' exists. You don't really need to import python as a module I believe. Try this:
import tensorflow.keras.backend as K
After having installed libgdcm-tools (2.6.6-3) on my system (via apt install libgdcm-tools) I am not longer able to import pydicom in Python. When running import pydicom as pdc I got the following error
AttributeError: module 'gdcm' has no attribute 'DataElement'.
Removing libgdcm-tools does not solve the issue.
I am working with Python 3.7 and pydicom 2.0.0 in Ubuntu 18.04.
Indeed #scaramallion's comment pointed me in the right direction. I didnt't have a gcdm directory in the working directory, but in my home directory. Removing that directory solved the problem.
After running sudo pip install google.cloud.pubsub
I am running the following python code in ubtunu google compute engine:
import google.cloud.pubsub_v1
I get the following error when importing this:
ImportError: No module named pubsub_v1 attribute 'SubscriberClient'
Can anyone tell me how to fix this?
Update your google-cloud-pubsub to the latest version. It should resolve the issue