WJA
WJA

Reputation: 7004

Pycharm cannot find reference `cloud` in "__init__.pyi" for google.cloud, but code does execute

I am using poetry with pyenv to manage dependencies. My pyproject.toml looks as follows:

[tool.poetry]
name = "hello-world"
version = "0.1.0"
description = "None"
authors = ["Hello <[email protected]>"]
readme = "README.md"
keywords = []

[tool.poetry.dependencies]
python = ">=3.9,<3.11"
google-cloud = "^0.34.0"
google-cloud-core = "^2.3.2" 
google-cloud-bigquery-datatransfer = "^3.7.1"
google-cloud-bigquery = "^3.3.2"
google-cloud-firestore = "^2.5.2"

[[tool.poetry.source]]
name = "ngt-pypi"
url = "link/to/private/package/abc-python/simple/"
default = false
secondary = true

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

Assuming pyenv is installed (and using version 3.9.6), I install the dependencies by running:

poetry config virtualenvs.in-project true
poetry install

After this, I confirm that in my interpreter I have the latest versions of the google cloud repositories installed.

Nevertheless, when I try to create a code and import bigquery:

from google.cloud import bigquery

I see on the Pycharm editor that it has not been found. The code however does execute, and there are no errors. What can be done to resolve this issue?

enter image description here

Upvotes: 1

Views: 451

Answers (1)

Mazlum Tosun
Mazlum Tosun

Reputation: 6572

For PyCharm and IntelliJ, you can do the following actions :

  • Open the menu file/Project Structure
  • Click on SDKs and the plus button

enter image description here

  • Click on the Add Python sdk

enter image description here

  • Click on the Poetry environment

enter image description here

  • It will detect your current Poetry env and create the sdk in PyCharm
  • Then in Project settings section, select the sdk created previously

enter image description here

I usually use Pipenv instead of Peoetry but the principle is the same with PyCharm.

Upvotes: 3

Related Questions