C3W1 Lab 2 Error from tfx.components import ImportExampleGen

Hello all,

I am trying to run the second lab of week one but I keep getting this error message in the import section:


AttributeError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pkg_resources/init.py in _dep_map(self)
3015 try:
→ 3016 return self.__dep_map
3017 except AttributeError:

24 frames
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
AttributeError: _pkg_info
During handling of the above exception, another exception occurred:

FileNotFoundError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pkg_resources/init.py in _get(self, path)
1609
1610 def _get(self, path):
→ 1611 with open(path, ‘rb’) as stream:
1612 return stream.read()
1613

FileNotFoundError: [Errno 2] No such file or directory: ‘/usr/local/lib/python3.7/dist-packages/google_api_core-1.26.3.dist-info/METADATA’

I have reset the kernel several times, once I received the message:


KeyError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pkg_resources/init.py in requires(self, extras)
2738 try:
→ 2739 deps.extend(dm[safe_extra(ext)])
2740 except KeyError as e:

KeyError: ‘grpc’

The above exception was the direct cause of the following exception:

UnknownExtra Traceback (most recent call last)
16 frames
/usr/local/lib/python3.7/dist-packages/pkg_resources/init.py in requires(self, extras)
2741 raise UnknownExtra(
2742 "%s has no such extra feature r" (self, ext)
→ 2743 ) from e
2744 return deps
2745

UnknownExtra: google-api-core 1.26.3 has no such extra feature ‘grpc’

I noticed that during TFX install I got the message:

ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pandas-gbq 0.13.3 requires google-cloud-bigquery[bqstorage,pandas]<2.0.0dev,>=1.11.1, but you have google-cloud-bigquery 2.30.1 which is incompatible.
multiprocess 0.70.12.2 requires dill>=0.3.4, but you have dill 0.3.1.1 which is incompatible.
jupyter-console 5.2.0 requires prompt-toolkit<2.0.0,>=1.0.0, but you have prompt-toolkit 3.0.22 which is incompatible.
google-colab 1.0.0 requires ipython~=5.5.0, but you have ipython 7.29.0 which is incompatible.
google-colab 1.0.0 requires requests~=2.23.0, but you have requests 2.26.0 which is incompatible.
datascience 0.10.6 requires folium==0.2.1, but you have folium 0.8.3 which is incompatible.
WARNING: Running pip as the ‘root’ user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: 12. Virtual Environments and Packages — Python 3.12.0 documentation
WARNING: Upgrading ipython, ipykernel, tornado, prompt-toolkit or pyzmq can
cause your runtime to repeatedly crash or behave in unexpected ways and is not
recommended. If your runtime won’t connect or execute code, you can reset it
with “Factory reset runtime” from the “Runtime” menu.
WARNING: The following packages were previously imported in this runtime:
[IPython,google,prompt_toolkit]
You must restart the runtime in order to use newly installed versions.

Do you know how can I solve this error ?

Hi @ecram , Welcome to discourse!

Did you restart runtime after installing TFX in the first code block? I guess that should prevent the error in the import section.

Good luck and best regards,
Maarten

Thank you Maarten, this help me to solve the issue.