python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
30.94k stars 2.25k forks source link

Dependency showing up in 'poetry show' and successfully installed, but not found when importing in poetry shell #8708

Closed FelipeDiaz98 closed 9 months ago

FelipeDiaz98 commented 9 months ago

Hi, I correctly installed tensorflow in a new poetry project, all the necessary dependencies were resolved and installed, and after installation, using poetry show shows all the different dependencies necessary to run tensorflow, including it itself. But when launch a poetry shell and then run a jupyter notebook and try to import tensorflow I keep getting an error saying there is no tensorflow package. I thought this might be a jupyter issue, so I tried directly checking the installed tensforflow version with python3 -c 'import tensorflow as tf; print(tf.__version__)', but I also get the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'

Poetry version: 1.4.2 CUDA: 11.8 os: windows 10

toml file:

[tool.poetry]
name = "tf-project"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "tf_project"}]

[tool.poetry.dependencies]
python = ">=3.9, <3.12"

[tool.poetry.group.dev.dependencies]
tensorflow = ">=2.10.0, <2.12.0"
tensorflow-io-gcs-filesystem = "^0.31.0"
opencv-python = "^4.7.0"
jupyter = "^1.0.0"
fs = "^2.4.16"

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

poetry show log:

absl-py                      2.0.0      Abseil Python Common Libraries, see https://github.com/abseil/abseil-py.
anyio                        4.1.0      High level compatibility layer for multiple asynchronous event loop impleme...
appdirs                      1.4.4      A small Python module for determining appropriate platform-specific dirs, e...
argon2-cffi                  23.1.0     Argon2 for Python
argon2-cffi-bindings         21.2.0     Low-level CFFI bindings for Argon2
arrow                        1.3.0      Better dates & times for Python
asttokens                    2.4.1      Annotate AST trees with source code positions
astunparse                   1.6.3      An AST unparser for Python
async-lru                    2.0.4      Simple LRU cache for asyncio
attrs                        23.1.0     Classes Without Boilerplate
babel                        2.13.1     Internationalization utilities
beautifulsoup4               4.12.2     Screen-scraping library
bleach                       6.1.0      An easy safelist-based HTML-sanitizing tool.
cachetools                   5.3.2      Extensible memoizing collections and decorators
certifi                      2023.11.17 Python package for providing Mozilla's CA Bundle.
cffi                         1.16.0     Foreign Function Interface for Python calling C code.
charset-normalizer           3.3.2      The Real First Universal Charset Detector. Open, modern and actively mainta...
colorama                     0.4.6      Cross-platform colored terminal text.
comm                         0.2.0      Jupyter Python Comm implementation, for usage in ipykernel, xeus-python etc.
debugpy                      1.8.0      An implementation of the Debug Adapter Protocol for Python
decorator                    5.1.1      Decorators for Humans
defusedxml                   0.7.1      XML bomb protection for Python stdlib modules
exceptiongroup               1.2.0      Backport of PEP 654 (exception groups)
executing                    2.0.1      Get the currently executing AST node of a frame, and other information
fastjsonschema               2.19.0     Fastest Python implementation of JSON schema
flatbuffers                  23.5.26    The FlatBuffers serialization format for Python
fqdn                         1.5.1      Validates fully-qualified domain names against RFC 1123, so that they are a...
fs                           2.4.16     Python's filesystem abstraction layer
gast                         0.4.0      Python AST that abstracts the underlying Python version
google-auth                  2.23.4     Google Authentication Library
google-auth-oauthlib         0.4.6      Google Authentication Library
google-pasta                 0.2.0      pasta is an AST-based Python refactoring library
grpcio                       1.59.3     HTTP/2-based RPC framework
h5py                         3.10.0     Read and write HDF5 files from Python
idna                         3.4        Internationalized Domain Names in Applications (IDNA)
importlib-metadata           6.8.0      Read metadata from Python packages
ipykernel                    6.26.0     IPython Kernel for Jupyter
ipython                      8.18.0     IPython: Productive Interactive Computing
ipywidgets                   8.1.1      Jupyter interactive widgets
isoduration                  20.11.0    Operations with ISO 8601 durations
jedi                         0.19.1     An autocompletion tool for Python that can be used for text editors.
jinja2                       3.1.2      A very fast and expressive template engine.
json5                        0.9.14     A Python implementation of the JSON5 data format.
jsonpointer                  2.4        Identify specific nodes in a JSON document (RFC 6901)
jsonschema                   4.20.0     An implementation of JSON Schema validation for Python
jsonschema-specifications    2023.11.1  The JSON Schema meta-schemas and vocabularies, exposed as a Registry
jupyter                      1.0.0      Jupyter metapackage. Install all the Jupyter components in one go.
jupyter-client               8.6.0      Jupyter protocol implementation and client libraries
jupyter-console              6.6.3      Jupyter terminal console
jupyter-core                 5.5.0      Jupyter core package. A base package on which Jupyter projects rely.
jupyter-events               0.9.0      Jupyter Event System library
jupyter-lsp                  2.2.0      Multi-Language Server WebSocket proxy for Jupyter Notebook/Lab server
jupyter-server               2.10.1     The backend—i.e. core services, APIs, and REST endpoints—to Jupyter web app...
jupyter-server-terminals     0.4.4      A Jupyter Server Extension Providing Terminals.
jupyterlab                   4.0.9      JupyterLab computational environment
jupyterlab-pygments          0.3.0      Pygments theme using JupyterLab CSS variables
jupyterlab-server            2.25.2     A set of server components for JupyterLab and JupyterLab like applications.
jupyterlab-widgets           3.0.9      Jupyter interactive widgets for JupyterLab
keras                        2.11.0     Deep learning for humans.
libclang                     16.0.6     Clang Python Bindings, mirrored from the official LLVM repo: https://github...
markdown                     3.5.1      Python implementation of John Gruber's Markdown.
markupsafe                   2.1.3      Safely add untrusted strings to HTML/XML markup.
matplotlib-inline            0.1.6      Inline Matplotlib backend for Jupyter
mistune                      3.0.2      A sane and fast Markdown parser with useful plugins and renderers
nbclient                     0.9.0      A client library for executing notebooks. Formerly nbconvert's ExecutePrepr...
nbconvert                    7.11.0     Converting Jupyter Notebooks
nbformat                     5.9.2      The Jupyter Notebook format
nest-asyncio                 1.5.8      Patch asyncio to allow nested event loops
notebook                     7.0.6      Jupyter Notebook - A web-based notebook environment for interactive computing
notebook-shim                0.2.3      A shim layer for notebook traits and config
numpy                        1.26.2     Fundamental package for array computing in Python
oauthlib                     3.2.2      A generic, spec-compliant, thorough implementation of the OAuth request-sig...
opencv-python                4.8.1.78   Wrapper package for OpenCV python bindings.
opt-einsum                   3.3.0      Optimizing numpys einsum function
overrides                    7.4.0      A decorator to automatically detect mismatch when overriding a method.
packaging                    23.2       Core utilities for Python packages
pandocfilters                1.5.0      Utilities for writing pandoc filters in python
parso                        0.8.3      A Python Parser
platformdirs                 4.0.0      A small Python package for determining appropriate platform-specific dirs, ...
prometheus-client            0.19.0     Python client for the Prometheus monitoring system.
prompt-toolkit               3.0.41     Library for building powerful interactive command lines in Python
protobuf                     3.19.6     Protocol Buffers
psutil                       5.9.6      Cross-platform lib for process and system monitoring in Python.
pure-eval                    0.2.2      Safely evaluate AST nodes without side effects
pyasn1                       0.5.1      Pure-Python implementation of ASN.1 types and DER/BER/CER codecs (X.208)
pyasn1-modules               0.3.0      A collection of ASN.1-based protocols modules
pycparser                    2.21       C parser in Python
pygments                     2.17.2     Pygments is a syntax highlighting package written in Python.
python-dateutil              2.8.2      Extensions to the standard Python datetime module
python-json-logger           2.0.7      A python library adding a json log formatter
pywin32                      306        Python for Window Extensions
pywinpty                     2.0.12     Pseudo terminal support for Windows from Python.
pyyaml                       6.0.1      YAML parser and emitter for Python
pyzmq                        25.1.1     Python bindings for 0MQ
qtconsole                    5.5.1      Jupyter Qt console
qtpy                         2.4.1      Provides an abstraction layer on top of the various Qt bindings (PyQt5/6 an...
referencing                  0.31.0     JSON Referencing + Python
requests                     2.31.0     Python HTTP for Humans.
requests-oauthlib            1.3.1      OAuthlib authentication support for Requests.
rfc3339-validator            0.1.4      A pure python RFC3339 validator
rfc3986-validator            0.1.1      Pure python rfc3986 validator
rpds-py                      0.13.1     Python bindings to Rust's persistent data structures (rpds)
rsa                          4.9        Pure-Python RSA implementation
send2trash                   1.8.2      Send file to trash natively under Mac OS X, Windows and Linux
setuptools                   69.0.2     Easily download, build, install, upgrade, and uninstall Python packages
six                          1.16.0     Python 2 and 3 compatibility utilities
sniffio                      1.3.0      Sniff out which async library your code is running under
soupsieve                    2.5        A modern CSS selector implementation for Beautiful Soup.
stack-data                   0.6.3      Extract data from python stack frames and tracebacks for informative displays
tensorboard                  2.11.2     TensorBoard lets you watch Tensors Flow
tensorboard-data-server      0.6.1      Fast data loading for TensorBoard
tensorboard-plugin-wit       1.8.1      What-If Tool TensorBoard plugin.
tensorflow                   2.11.1     TensorFlow is an open source machine learning framework for everyone.
tensorflow-estimator         2.11.0     TensorFlow Estimator.
tensorflow-io-gcs-filesystem 0.31.0     TensorFlow IO
termcolor                    2.3.0      ANSI color formatting for output in terminal
terminado                    0.18.0     Tornado websocket backend for the Xterm.js Javascript terminal emulator lib...
tinycss2                     1.2.1      A tiny CSS parser
tomli                        2.0.1      A lil' TOML parser
tornado                      6.3.3      Tornado is a Python web framework and asynchronous networking library, orig...
traitlets                    5.13.0     Traitlets Python configuration system
types-python-dateutil        2.8.19.14  Typing stubs for python-dateutil
typing-extensions            4.8.0      Backported and Experimental Type Hints for Python 3.8+
uri-template                 1.3.0      RFC 6570 URI Template Processor
urllib3                      2.1.0      HTTP library with thread-safe connection pooling, file post, and more.
wcwidth                      0.2.12     Measures the displayed width of unicode strings in a terminal
webcolors                    1.13       A library for working with the color formats defined by HTML and CSS.
webencodings                 0.5.1      Character encoding aliases for legacy web content
websocket-client             1.6.4      WebSocket client for Python with low level API options
werkzeug                     3.0.1      The comprehensive WSGI web application library.
wheel                        0.41.3     A built-package format for Python
widgetsnbextension           4.0.9      Jupyter interactive widgets for Jupyter Notebook
wrapt                        1.16.0     Module for decorators, wrappers and monkey patching.
zipp                         3.17.0     Backport of pathlib-compatible object wrapper for zip files

Thanks in advance for any help. Let me know if there is any important info I might have failed to include here.

dimbleby commented 9 months ago

duplicate #8271, please close

FelipeDiaz98 commented 9 months ago

duplicate #8271, please close

Already checked #8271 and the solution provided doesn't work, it either keeps trying to install tensorflow-io-gcs-filesystem v0.34.0 which it shouldn't, and when forced to install the correct version, it either tries to install tensorflow-intel which it also shouldn't, sometimes failing and sometimes installing it. Regardless of all this, if the correct i/o package and all other installations are carried successfully, it keeps saying tensorflow cannot be imported. But thanks for hinting towards a possible solution.

dimbleby commented 9 months ago

this is nevertheless a duplicate of #8271: please close this one and continue any further discussion there

github-actions[bot] commented 6 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.