Issue
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?
Solution
For PyCharm
and IntelliJ
, you can do the following actions :
- Open the menu
file/Project Structure
- Click on SDKs and the
plus
button
- Click on the
Add Python sdk
- Click on the
Poetry environment
- It will detect your current
Poetry env
and create thesdk
inPyCharm
- Then in
Project settings
section, select thesdk
created previously
I usually use Pipenv
instead of Peoetry
but the principle is the same with PyCharm
.
Answered By - Mazlum Tosun Answer Checked By - Cary Denson (WPSolving Admin)