in Anaconda3 (python3.7) I made an Tensorflow environment named tf. Now I tried to install OpenCv into this environment. I tried several:
conda install --name tf opencv
conda install --name tf -c conda-forge opencv
I tried also inside the tf folder:
pip install opencv-python
all runs and installed something. But when I try to run my code the error appears that it couldn't find cv2.
I import it with
import cv2 as cv.
I run the code through Conda in Visual Studio Code. Ans I selcted the Interpreter Path Python3.7.6 64-bit('tf':conda)
The installation of numpy and matplotlib into this environment worked.
Does anyone know what I've done wrong? Or how I can combine these two, OpenCV and Tensorflow, through anaconda?
Thanks a lot
Use following commands
conda create -n tf tensorflow
conda activate tf
Then use
pip install opencv-python
Related
I am using miniconda, v4.13.0, I can install Tensorflow using conda install tensorflow to my conda environment if its Python version 3.9.* However I would like to use Python 3.10.*
If the Python version is 3.10.* in my conda environment then command conda install tensorflow gives the specification incompatibility error:
tensorflow -> python[version='3.5.|3.6.|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|3.8.|3.7.|3.9.*']
Question
Is there any way to install Tensorflow via conda where the Python version is 3.10.*?
You can use the below command to install TensorFlow using python 3.10:
conda create --name tf python=3.10
conda activate tf
conda install tensorflow
Please check this link for reference.
You can find here tensorflow github PR
https://github.com/tensorflow/addons/pull/2635
I am using python notebooks using Anaconda for datascience and I'm trying to install tensor flow.
I have followed this tutorial:
https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html
and everything is fine. I can type import tensorflow as tf as written and I haven't errors. But when I return to python notebooks and I write import tensorflow as tf i continue to have this error:
No module named 'tensorflow'
How can I fix it?
You should have installed Jupiter notebook within your Conda environment.
conda activate <your-environment-name>
conda install -c anaconda jupyter
This solved the same problem for me.
Please follow the below steps to easily use your anaconda environment from jupyter notebook.
conda create -n myenv
source activate myenv
python -m ipykernel install --user --name myenv --display-name "Python(myenv)"
You can now switch the kernel in jupyter notebook and import all the packages that you have installed in your conda environment.
ModuleNotFoundError Traceback (most recent call last)
in ()
11 import numpy as np
12
---> 13 import tensorflow as tf
14
15
ModuleNotFoundError: No module named 'tensorflow'
I was looking for a similar issue (unable to import tensorflow in jupyter) and found that maybe most answers are outdated because now conda installs tf in its own environment.
The most useful thing I found is:
https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/
which explains in very few steps how to install tf or tf-gpu in its own environment.
Then my problem was that the jupyter notebook is in its own base environment, not in the tf-gpu environment. How to work with that from a jupyter notebook based on the base environment?
The solution comes from the very helpful answer from Nihal Sangeeth to this question
https://stackoverflow.com/questions/53004311/how-to-add-conda-environment-to-jupyter-lab
conda activate tf-gpu
(tf-gpu)$ conda install ipykernel
(tf-gpu)$ ipython kernel install --user --name=<any_name_you_like_for_kernel>
(tf-gpu)$ conda deactivate
Close and reopen your jupyter notebook.
Then in your jupyter notebook you will find the option, under "kernel" of "change kernel". Change kernel to your newly created kernel and you will be able to import tensorflow as tf and go on from there.
Hope it helps somebody
You can use following commands to import by Anaconda prompt:
conda install tensorflow
it will download all tensorflow environment setup.
then you can check any where:
import tensorflow
This might occur from several issues
Is tensorflow installed ?
pip install --upgrade tensorflow
Are you sure you're in the same conda enviroment which has tensorflow isntalled ?
conda env list
# conda environments:
deep-learning /Users/wassimseifeddine/anaconda/anaconda3/envs/deep-learning
root /Users/wassimseifeddine/anaconda/anaconda3
try switching between this environments source activate <env-name> and trying pip freeze to chech if tensorflow is installed.
I am trying to install tensorflow on Ananconda2 in windows 64 bit. I've tried the following steps:
conda create --name tensorflow python=3.5
activate tensorflow
conda install -c conda-forge tensorflow
Tensorflow got installed successfully and i could check that in Anaconda prompt.
However, when I open my python2 Jupyter notebook and try with the following:
import tensorflow as tf
I get an error says "module tensorflow is not found". Could you please help!
Solution:- (Note:- This will surely work for all!!)
Step 1:- conda search python
Step 2:- conda install python=3.5.2
Step 3:- pip install tensorflow
Step 4:- import tensorflow as tf
Done!!
I am using an Ubuntu docker image. I've installed Anaconda on it with no issues. I'm not trying to install tensorflow, using the directions on the tensorflow website:
conda create --name tensorflow python=3.5
source activate tensorflow
<tensorflow> conda install -c conda-forge tensorflow
It installs with no errors. However, when I import in iPython, it tells me there is no module tensorflow. But if I import when in Python, it works fine.
What's going on and how do I fix it?
You have to install IPython in the conda environment
source activate tensorflow
conda install ipython
I went through the same thing. We are installing tensorflow in different conda environment. So It may not consist of all the packages. I needed to install jupyter notebook separately in order to work.