Hi I am using Jupyter notebook to run my python script.I did all the steps to install tensorflow. When I do list env I see tensorflow installed but when I write a script using tensor flow. I get the following error.
ImportError Traceback (most recent call last)
<ipython-input-1-b2d6c7d62f65> in <module>()
2 import numpy as np
3 #import tflearn
----> 4 import tensorflow as tf
5 import tflearn
6 #from tflearn.data_utils import to_categorical
ImportError: No module named 'tensorflow'
Can anyone please help in how to debug
I have followed the following steps
1.conda create --name test python=3.5
2.activate test
3.conda install numpy matplotlib pandas jupyter notebook
4. conda install tensorflow scipy
all the installations were successfull. Except in hdf5 i got error saying revuild using conda > 2.0
If you're trying to import tensorflow in ipython, you should also make sure that ipython is installed in the same environment. And if you run
ipython notebook
This will launch the default ipython (/usr/bin/ipython). You don't want that. So, run venv/bin/ipython instead
Related
I cant import pycaret in a google colab
Here are all the steps I had taken:
Change python version to 3.8
Installed pip
I then ran
!pip install pycaret
import pycaret
the install works, but then
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-27-fdea18e6876c> in <module>
1 get_ipython().system('pip install pycaret ')
----> 2 import pycaret
ModuleNotFoundError: No module named 'pycaret'
I must be doing something very wrong!
In troubleshooting I also pip installed numpy and pandas which both imported just fine
For importing use this, this is one is for classification:
from pycaret.classification import *
And for regression:
from pycaret.regression import *
For NLP:
from pycaret.nlp import *
!pip install pycaret
should work without any issues. I have used it multiple times on Google Colab. Alternately, you can use
pip install --pre pycaret
I am trying to use XGBoost on Sagemaker notebook.
I am using conda_python3 kernel, and the following packages are installed:
py-xgboost-mutex
libxgboost
py-xgboost
py-xgboost-gpu
But once I am trying to import xgboost it fails on import:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-5-5943d1bfe3f1> in <module>()
----> 1 import xgboost as xgb
ModuleNotFoundError: No module named 'xgboost'
In Sagemaker notebooks use the below steps
a) If in Notebook
i) !type python3
ii) Say the above is /home/ec2-user/anaconda3/envs/python3/bin/python3 for you
iii) !/home/ec2-user/anaconda3/envs/python3/bin/python3 -m pip install xgboost
iv) import xgboost
b) If using Terminal
i) conda activate conda_python3
ii) pip install xgboost
Disclaimer : sometimes the installation would fail with gcc version ,in that case update pip version before running install
I tried to execute this line in my application in Jupyter notebook.
from tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets
I get the following error:
.conda/envs/py27/lib/python2.7/site-packages/tensorflow/contrib/__init__.py in <module>()
23
24 # Add projects here, they will show up under tf.contrib.
---> 25 from tensorflow.contrib import batching
26 from tensorflow.contrib import bayesflow
27 from tensorflow.contrib import cloud
ImportError: cannot import name batching
I do not get this error if I ran it like this:
python -c "from tensorflow.examples.tutorials.mnist import input_data"
Can someone tell me what's causing the error in Jupyter Notebook
I have run into similar issue with importing libraries from jupyter notebook, and the problem has always been that I forgot to install jupyter in my new conda environment, but jupyter is installed in the root environment.
Based on the error given, make sure you have jupyter installed within the py27 conda environment. If it not installed, it will default to open the one in the root environment.
So in the terminal:
source activate py27 # activate py27 if on windows
conda install jupyter
I got this error in Jupyter Notebook.
this may duplicate post but no any proper answer found
Neither below links helped me to solve this.
No module named tensorflow in jupyter
No module named tensor flow -- iPython notebook
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-b88de1945047> in <module>()
1 get_ipython().magic('matplotlib inline')
2 import numpy as np
----> 3 import tensorflow as tf
4 from tensorflow.contrib import rnn
5 import data_loader
ModuleNotFoundError: No module named 'tensorflow'
B:S -
enter image description here
I faced the same problem at first. I realized that in the conda-->envs -->
tensorflow-->Scripts-->idle.exe, is the python 3.5.5 shell. Where you can import tensorflow without any problems. So, I chaged the directory as C:\Users\Temp\Anconda3..... and then activated and deactived the tensorflow once. In the next step I entered the python mode and import tensorflow as tf worked right.
I had the same problem and I think I've found the solution!
See, I had installed both CPU and GPU versions of Tensorflow at the same time which apparently is wrong. Then, I uninstalled the GPU version, it didn't work this time either. So I uninstalled both of them and reinstalled the CPU version. It's working now.
BTW I'm on Win10(1803) and python 3.6.5 (not using anaconda.)
You can execute the following instructions and command to solve the issue: (do not include inverted commas)
Open Anaconda Prompt
type: "create --name py3-TF2.0 python = 3"
press "y" to continue
After successful completion:
type "conda activate py3-TF2.0"
type "pip install matplotlib"
type "pip install tensorflow==2.1.0"
type "conda deactivate"
type "pip install ipykernel"
type "conda install nb_conda_kernels"
Now exit the Anaconda prompt and open the Anaconda Navigator application. Switch to "py3-TF2.0" from the base environment using the Environment tab. Install Jupyter in the specified environment.
After successful installation, open Jupyter notebook and switch to "py3-TF2.0" kernel using Kernel Tab.
You're good to go for using TensorFlow 2.
Make Sure you use Anaconda 2020.02 or lower version.
As new version does not support TensorFlow 2.
import tensorflow as tf Traceback (most recent call last):
File "<ipython-input-5-41389fad42b5>", line 1, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
I am getting the following error after installation of tensorflow in anaconda using windows. I have followed the tensorflow installation steps
At first it was running properly but when i tried to uninstall and reinstall tensorflow, this error pops up. I tried uninstalling Anaconda itself and reinstalling but was of no help. Tensorflow is getting installed but when i try the import step it shows the above error.
Solved: Python 3.6 is incompatible with tensorflow and had to create tensorflow environment for python 3.5.
conda create -n tensorflow python=3.5 anaconda
Activated it in command prompt and launched spyder from it which changed my python version to 3.5. Now was able to import tensorflow properly.
If you installed tensorflow using Anaconda inside an Anaconda environment, you will need to activate this environment. Only then can you import tensorflow.