I am working on google colab with the segmentation_models library. It worked perfectly the first week using it, but now it seems that I can't import the library anymore. Here is the error message, when I execute import segmentation_models as sm :
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-6f48ce46383f> in <module>
1 import tensorflow as tf
----> 2 import segmentation_models as sm
3 frames
/usr/local/lib/python3.8/dist-packages/efficientnet/__init__.py in init_keras_custom_objects()
69 }
70
---> 71 keras.utils.generic_utils.get_custom_objects().update(custom_objects)
72
73
AttributeError: module 'keras.utils.generic_utils' has no attribute 'get_custom_objects'
Colab uses tensorflow version 2.11.0.
I did not find any information about this particular error message. Does anyone know where the problem may come from ?
Encountered the same issue sometimes. How I solved it:
open the file keras.py, change all the 'init_keras_custom_objects' to 'init_tfkeras_custom_objects'.
the location of the keras.py is in the error message. In your case, it should be in /usr/local/lib/python3.8/dist-packages/efficientnet/
my version of python is 3.6.9
and I tried install many versions of google-cloud-pubsub
2.1.0
1.5.0
1.3.0 .....
but I still have problem import
" "
the error message is
""" from google.cloud import pubsub_v1
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-30-5ae969a9c485> in <module>
----> 1 from google.cloud import pubsub_v1
~\AppData\Local\Continuum\anaconda3\envs\jb\lib\site-packages\google\cloud\pubsub_v1\__init__.py in <module>
15 from __future__ import absolute_import
16
---> 17 from google.cloud.pubsub_v1 import types
18 from google.cloud.pubsub_v1 import publisher
19 from google.cloud.pubsub_v1 import subscriber
~\AppData\Local\Continuum\anaconda3\envs\jb\lib\site-packages\google\cloud\pubsub_v1\types.py in <module>
17 import sys
18
---> 19 from google.api import http_pb2
20 from google.iam.v1 import iam_policy_pb2
21 from google.iam.v1 import policy_pb2
~\AppData\Local\Continuum\anaconda3\envs\jb\lib\site-packages\google\api\http_pb2.py in <module>
33 syntax="proto3",
34 serialized_options=b"\n\016com.google.apiB\tHttpProtoP\001ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\370\001\001\242\002\004GAPI",
---> 35 serialized_pb=b'\n\x15google/api/http.proto\x12\ngoogle.api"T\n\x04Http\x12#\n\x05rules\x18\x01 \x03(\x0b\x32\x14.google.api.HttpRule\x12\'\n\x1f\x66ully_decode_reserved_expansion\x18\x02 \x01(\x08"\x81\x02\n\x08HttpRule\x12\x10\n\x08selector\x18\x01 \x01(\t\x12\r\n\x03get\x18\x02 \x01(\tH\x00\x12\r\n\x03put\x18\x03 \x01(\tH\x00\x12\x0e\n\x04post\x18\x04 \x01(\tH\x00\x12\x10\n\x06\x64\x65lete\x18\x05 \x01(\tH\x00\x12\x0f\n\x05patch\x18\x06 \x01(\tH\x00\x12/\n\x06\x63ustom\x18\x08 \x01(\x0b\x32\x1d.google.api.CustomHttpPatternH\x00\x12\x0c\n\x04\x62ody\x18\x07 \x01(\t\x12\x15\n\rresponse_body\x18\x0c \x01(\t\x12\x31\n\x13\x61\x64\x64itional_bindings\x18\x0b \x03(\x0b\x32\x14.google.api.HttpRuleB\t\n\x07pattern"/\n\x11\x43ustomHttpPattern\x12\x0c\n\x04kind\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\tBj\n\x0e\x63om.google.apiB\tHttpProtoP\x01ZAgoogle.golang.org/genproto/googleapis/api/annotations;annotations\xf8\x01\x01\xa2\x02\x04GAPIb\x06proto3',
36 )
37
TypeError: __init__() got an unexpected keyword argument 'serialized_options'
"""
I tried change version of protobuf, but i could not solve this problem...
how to fix this issue???
Please help me...
I have tensorflow version "1.14.0" and pip3 is also updated. But when I do:-
import tensorflow as tf
I get this error:
AttributeError: module 'tensorflow.python.ops.resource_variable_ops' has no attribute 'UninitializedVariable'
Tensorflow hub has version 0.5.0. Some answers on stack overflow have suggested that tensorflow version should be greater than 1.7.0 and mine is greater and still I don't know why is hub not being imported. The complete traceback of error is:-
AttributeError Traceback (most recent call last)
<ipython-input-24-d70b4e927300> in <module>
1 from sklearn.model_selection import train_test_split
2 import tensorflow as tf
----> 3 import tensorflow_hub as hub
~/.local/lib/python3.6/site-packages/tensorflow_hub/__init__.py in <module>
27 # error message is thrown instead of an obscure error of missing
28 # symbols at executing the imports.
---> 29 from tensorflow_hub.estimator import LatestModuleExporter
30 from tensorflow_hub.estimator import register_module_for_export
31 from tensorflow_hub.feature_column import image_embedding_column
~/.local/lib/python3.6/site-packages/tensorflow_hub/estimator.py in <module>
23 from absl import logging
24 import tensorflow as tf
---> 25 from tensorflow_hub import tf_utils
26 from tensorflow_hub import tf_v1
27
~/.local/lib/python3.6/site-packages/tensorflow_hub/tf_utils.py in <module>
31 # depending on TensorFlow internal implementation details.
32 # pylint: disable=g-direct-tensorflow-import
---> 33 from tensorflow.python.feature_column import feature_column_v2
34 # pylint: enable=g-direct-tensorflow-import
35
~/.local/lib/python3.6/site-packages/tensorflow/python/feature_column/feature_column_v2.py in <module>
164 from tensorflow.python.platform import tf_logging as logging
165 from tensorflow.python.training import checkpoint_utils
--> 166 from tensorflow.python.training.tracking import tracking
167 from tensorflow.python.util import deprecation
168 from tensorflow.python.util import nest
~/.local/lib/python3.6/site-packages/tensorflow/python/training/tracking/tracking.py in <module>
21 import weakref
22
---> 23 from tensorflow.python.eager import def_function
24 from tensorflow.python.eager import function as defun
25 from tensorflow.python.framework import dtypes
~/.local/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py in <module>
38
39
---> 40 class UnliftedInitializerVariable(resource_variable_ops.UninitializedVariable):
41 """Variable which does not lift its initializer out of function context.
42
AttributeError: module 'tensorflow.python.ops.resource_variable_ops' has no attribute 'UninitializedVariable'
I have tried uninstalling tf completely and then installing again, reinstalling tf hub and updating pip so far. Any help will be very much appreciated!
I have a problem with Django version conflicting.
when I run my Django project, I got message.
ImportError Traceback (most recent call last)
/usr/local/lib/python3.5/dist-packages/rest_framework/compat.py in <module>()
21 try:
---> 22 from django.urls import (
23 NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve
ImportError: cannot import name 'RegexURLPattern'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-1-0639a9fdda0c> in <module>()
1 from urllib.parse import urlencode, quote_plus
2 from urllib.request import Request, urlopen
----> 3 from hospital.serializers import HospitalSerializer
~/earlierdoctorserver/hospital/serializers.py in <module>()
----> 1 from rest_framework.serializers import ModelSerializer
2 from .models import Hospital
3
4 class HospitalSerializer(ModelSerializer):
5 class Meta:
/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py in <module>()
28 from django.utils.translation import ugettext_lazy as _
29
---> 30 from rest_framework.compat import JSONField as ModelJSONField
31 from rest_framework.compat import postgres_fields, set_many, unicode_to_repr
32 from rest_framework.exceptions import ErrorDetail, ValidationError
/usr/local/lib/python3.5/dist-packages/rest_framework/compat.py in <module>()
24 )
25 except ImportError:
---> 26 from django.core.urlresolvers import ( # Will be removed in Django 2.0
27 NoReverseMatch, RegexURLPattern, RegexURLResolver, ResolverMatch, Resolver404, get_script_prefix, reverse, reverse_lazy, resolve
28 )
ImportError: No module named 'django.core.urlresolvers'
Looking straight at the lines of code, my project does not have that statement, and there seems to be a problem with the package in the local repository. pip upgrades, etc. are all up to date, how do I fix them?
thanks.
I was getting a similar message trying to run python manage.py show_urls after upgrading to Django 2.
Upgrading django-extensions solved the issue for me, but in your case it looks like you need to upgrade your Compat and Rest Framework libraries.
I normally have no problem scouring the web for obscure python packages. However I cannot find this one. Does anyone know what the error is referring too?
Is there an easy way to dig into the source to figure out what modules it wants?
I know I shouldn't be bugging stackoverflow about every missing module I have so is there a method for debugging this myself?
These are the modules i've most recently installed for this project:
blist
beautifulsoup
requests
pymongo
SQLAlchemy
xmltodict
financial_fundamentals
I think the error is coming from SQLAlchemy but the error readout says something about vector_cache
Using the following line:
import financial_fundamentals.accounting_metrics as ac
I get:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-6-f1aecf47aa1b> in <module>()
----> 1 import financial_fundamentals.accounting_metrics as ac
C:\Python27\lib\site-packages\financialfundamentals-0.2.3-py2.7.egg\financial_fundamentals\accounting_metrics.py in <module>()
65 import financial_fundamentals.edgar as edgar
66
---> 67 #vector_cache.vector_cache
68 def earnings_per_share(required_data):
69 start, end = required_data.index[0], required_data.index[-1]
C:\Python27\lib\site-packages\vector_cache-0.1.0-py2.7.egg\vector_cache\_vector_cache.pyc in vector_cache(user_function)
19 # When the function name or location changes you're going to have to re-cache everything, bummer.
20 metric = user_function.__name__
---> 21 data_store = get_data_store()
22 #wraps(user_function)
23 def wrapper(required_data_df):
C:\Python27\lib\site-packages\vector_cache-0.1.0-py2.7.egg\vector_cache\__init__.py in _get_data_store(cls)
37 except IOError:
38 # no config in home directory
---> 39 return cls._default_data_store(db_dir=home)
40 else:
41 return cls._eval_config_code(code)
C:\Python27\lib\site-packages\vector_cache-0.1.0-py2.7.egg\vector_cache\__init__.py in _default_data_store(db_dir)
43 #staticmethod
44 def _default_data_store(db_dir):
---> 45 from sql_driver import SQLDataStore
46 import os
47 db_file_path = os.path.join(db_dir, 'vector_cache.db')
ImportError: No module named sql_driver