Reputation: 136
Im trying to use huggingface transformers library in my python project. I am a first time python programmer, and I am stuck on this error message, even though tensorflow has been installed on my machine:
>>> from transformers import pipeline
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
I have discovered that tensorflow does not exist, even though I have installed it via pip
. I have tried uninstalling it and reinstalling it, and but when I try to import the package, it just comes back as a ModuleNotFoundError
>>> import tensorflow
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import tensorflow
File "C:\Users\######\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
ModuleNotFoundError: No module named 'tensorflow.python
I have tried uninstalling and re-installing using pip
and conda
. I even tried installing pytorch
using the same methods. It always says that the package was succesfully installed, and yet the error persists.
I am using Python 3.9 and my OS is Windows 10. I dont know what I am doing wrong. But I know that a solution will definitely not be to uninstall and reinstall a package.
Pip version (pip -V
):
pip 21.1.3 from c:\users\######\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)
Python version (python -V
):
Python 3.9.5
Python path list
I tried comparing the output of sys.path
with the output of pip -V
.
The closest path I saw for the pip -V
path is down at the bottom, however I did not find the exact directory.
>>> import sys
>>> sys.path
['', 'C:\\windows\\system32', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\\python39.zip', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\\DLLs', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\\lib', 'C:\\Users\\######\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0', 'C:\\Users\\######\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python39\\site-packages', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.9_3.9.1520.0_x64__qbz5n2kfra8p0\\lib\\site-packages']
Closest path:
C:\Users\######\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages
Upvotes: 2
Views: 2696
Reputation:
From comments
You have multiple python interpreters installed, that is why installing stuff does not show in your python interpreter, use
pip -V
and compare it to the python version that appears in the interpreter. Remove one and use only one then your issue will be resolved (paraphrased from Dr.Snoopy)
Upvotes: 3