Skip to content

Python 3.12 requires setuptools package #2834

@fangyi-zhou

Description

@fangyi-zhou

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Is your feature request related to a problem? Please describe.

I cannot import vertexai in a fresh Python 3.12 virtual environment due to missing pkg_resources

fangyi@strength % python3 -m venv venv
fangyi@strength % . ./venv/bin/activate
(venv) fangyi@strength % pip install google-cloud-aiplatform
[...]
Installing collected packages: urllib3, six, pyasn1, protobuf, packaging, numpy, idna, grpcio, google-crc32c, charset-normalizer, certifi, cachetools, shapely, rsa, requests, python-dateutil, pyasn1-modules, proto-plus, googleapis-common-protos, google-resumable-media, grpcio-status, google-auth, grpc-google-iam-v1, google-api-core, google-cloud-core, google-cloud-storage, google-cloud-resource-manager, google-cloud-bigquery, google-cloud-aiplatform
pythonSuccessfully installed cachetools-5.3.1 certifi-2023.7.22 charset-normalizer-3.3.1 google-api-core-2.12.0 google-auth-2.23.3 google-cloud-aiplatform-1.35.0 google-cloud-bigquery-3.12.0 google-cloud-core-2.3.3 google-cloud-resource-manager-1.10.4 google-cloud-storage-2.12.0 google-crc32c-1.5.0 google-resumable-media-2.6.0 googleapis-common-protos-1.61.0 grpc-google-iam-v1-0.12.6 grpcio-1.59.0 grpcio-status-1.59.0 idna-3.4 numpy-1.26.1 packaging-23.2 proto-plus-1.22.3 protobuf-4.24.4 pyasn1-0.5.0 pyasn1-modules-0.3.0 python-dateutil-2.8.2 requests-2.31.0 rsa-4.9 shapely-2.0.2 six-1.16.0 urllib3-2.0.7

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: pip install --upgrade pip
(venv) fangyi@strength % python
Python 3.12.0 (main, Oct  2 2023, 00:00:00) [GCC 13.2.1 20230918 (Red Hat 13.2.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import vertexai
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/fangyi/tmp/venv/lib64/python3.12/site-packages/vertexai/__init__.py", line 17, in <module>
    from google.cloud.aiplatform import init
  File "/home/fangyi/tmp/venv/lib64/python3.12/site-packages/google/cloud/aiplatform/__init__.py", line 24, in <module>
    from google.cloud.aiplatform import initializer
  File "/home/fangyi/tmp/venv/lib64/python3.12/site-packages/google/cloud/aiplatform/initializer.py", line 22, in <module>
    import pkg_resources  # noqa: F401 # Note this is used after copybara replacement
    ^^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'pkg_resources'
>>> 

Describe the solution you'd like

Import succeeds without other actions.

Describe alternatives you've considered

Either downgrade to Python 3.11, or installing setuptools manually via pip install setuptools

Additional context

Python 3.12 release notes https://docs.python.org/3/whatsnew/3.12.html

gh-95299: Do not pre-install setuptools in virtual environments created with venv. This means that distutils, setuptools, pkg_resources, and easy_install will no longer available by default; to access these run pip install setuptools in the activated virtual environment.

Metadata

Metadata

Assignees

Labels

api: vertex-aiIssues related to the googleapis/python-aiplatform API.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions