Reputation: 63
English is not my mother tongue, so there might be some grammatical errors in my question.
Sorry about that.
Recently I needed to learn tensorflow. My python version is 3.9, it might be incompatible with tensorflow. So I installed anaconda and built a virtual environment named "tensorflow".I used VScode to run my code.
First,I activate environment "tensorflow" in VScode.PS C:\Users\57142\Desktop\Project files\GongYiRu'sArticle> conda activate tensorflow
My python version in this env.
PS C:\Users\57142\Desktop\Project files\GongYiRu'sArticle> python --version
Python 3.6.13 :: Anaconda, Inc.
My tensorflow-gpu version is 2.5.0.
Here are my pythonpath.
['', 'C:\\Users\\57142\\anaconda3\\envs\\tensorflow\\python36.zip', 'C:\\Users\\57142\\anaconda3\\envs\\tensorflow\\DLLs', 'C:\\Users\\57142\\anaconda3\\envs\\tensorflow\\lib', 'C:\\Users\\57142\\anaconda3\\envs\\tensorflow', 'C:\\Users\\57142\\anaconda3\\envs\\tensorflow\\lib\\site-packages']
But when I ran my code.I got this error. demo.py is my code. And "1" is its parameter.
PS C:\Users\57142\Desktop\Project files\GongYiRu'sArticle> .\simple-examples\data\demo.py 1
2021-12-09 18:19:51.635939: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Successfully opened dynamic library cudart64_110.dll
Traceback (most recent call last):
File "C:\Users\57142\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: Module use of python36.dll conflicts with this version of Python.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\57142\Desktop\Project files\GongYiRu'sArticle\simple-examples\data\demo.py", line 8, in <module>
import tensorflow as tf
File "C:\Users\57142\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\57142\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\57142\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\57142\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\57142\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\57142\anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: Module use of python36.dll conflicts with this version of Python.
Failed to load the native TensorFlow runtime.
After seveval attempts, a new question occured.When I ran my code using py -3.6 like this.
(tensorflow) C:\Users\57142\Desktop\Project files\GongYiRu'sArticle>py -3.6 simple-examples\data\demo.py 1
Python 3.6 not found!
Installed Pythons found by py Launcher for Windows
-3.9-64 *
It said "python 3.6 is not found". But I do have python 3.6.13 in my anaconda environment.
I googled almost every question like this. But I still have not solved this question. I will be very grateful if you can offer me some advice. Thank you!
Upvotes: 5
Views: 7999
Reputation:
As error says conflict in Python version, While creating conda environment install python version to avoid conflict.Looks there are two versions of Python(3.6 and 3.9) installed on your system.
conda create -n tf python=3.6 anaconda
#Activate environment
activate tf
#Install Tensorflow
conda install tensorflow==2.5
Upvotes: 2