Unable to access pip installed packages from anaconda jupyter notebooks - python

when i try to import tensorflow from jupyter notebooks. I'm facing a error No module named 'tensorflow' .
But i have installed tensorflow using pip command, and it available in this path c:\program files\python38\lib\site-packages.
please tell me how to access packages installed via pip from jupyter notebooks?

When you installed tensorflow you had a specific environment active and that is where tensorflow was installed. If you are using Anaconda and did not specify which environment to make active it installed it in the base environment. If you want to install tensorflow to a specific environment (lets call it tf) then start the anaconda prompt and enter the text conda activate tf. Then install tensorflow with pip in the same window. My recommendation is to install tensorflow with conda versus pip. conda installs tensorflow and also installs the cuda toolkit and the proper version of cuDNN. pip does not do that. If you install tensorflow with conda I believe it installs version 2.1, cuda toolkit version 10.1.243 and cuDNN version 7.6.5.

Related

In Conda environment, how to upgrade a package that is pip installed?

I use AWS SageMaker for ML software development. In SageMaker, there are several conda environments to choose from. I need to upgrade some packages in a conda environment that are pip installed. From my research, pip and conda are not compatible. So what is the best way to upgrade these pip-installed package?
As an example, the below image shows a conda_tensorflow_p36 environment and the keras package is pip installed. I want to upgrade the keras package to the current version. How do I do that?
You need to specify the name of the conda environment to use when upgrading, so change your conda upgrade keras command to:
conda upgrade -n conda_tensorflow_p36 keras
EDIT: Alternatively, the Install External Libraries and Kernels documentation page for SageMaker gives an example script that downloads/installs an entirely new version/instance of miniconda from the notebook. Then any packages you need (including keras) can be installed into that miniconda instance, independent of the versions provided by SageMaker.

Importing custom built pip installed tensorflow to conda environment

I'm a newbie to python and tensorflow and after installing a custom wheel version of tensorflow 1.5.0 using pip install, I created a conda environment using Pycharm. On activating the environment, I observed that the tensorflow isn't one of its packages.
Am just wondering if there was any way I could import the pip installed tensorflow package into the environment without building it with conda and reinstalling it in the environment? Thanks
Edited:
Discovered that you have to install it in the new environment before
you can use it

tensorflow install with conda conflict - UnsatisfiableError

Tried to install tensorflow using conda and its throwing a spec conflict error. I do not have python 3.5 installed
conda install -c conda-forge tensorflow
Fetching package metadata ...............
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
- python 3.6*
- tensorflow -> python 3.5*
Use "conda info <package>" to see the dependencies for each package.
python --version
Python 3.6.0 :: Anaconda custom (64-bit)
I cannot seem to run tensorflow on the normal python IDE and it says module not found. So I installed Anaconda and everything seems good except for tensorflow. Any way to install this?
You seem to be installing tensorflow for python3.5 on a python3.6 environment. I would suggest you to create a seperate python environment for tensorflow. You can do it as follows
conda create -n Tensorflow anaconda python=3.5
This will create a anaconda environment called Tensorflow and install all the anaconda packages. You can also specify any other python distribution of your choice. Be sure you download the right tensorflow distribution depending on the python version you choose.
Then activate the newly created anaconda environment as follows
source activate Tensorflow
On windows
activate Tensorflow
This will switch the python environment. Then proceed to installing Tensorflow using pip as follows
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.1.0-cp35-cp35m-win_amd64.whl
If you wish to install tensorflow with GPU support, you should install CUDA toolkit and the CUDNNv5.1. More details here

Installing tensorflow with Pip Python 3.5 anaconda in windows

I am trying to install Tensorslow on my Windows 7 64 bit computer.
I have installed Anaconda with Python 3.5.
After that I did
conda install theano
it is successfully done.
conda install mingw libpython
successfully done.
pip install tensorflow
Error
I am not able to install Tensorflow in the same way I installed these other packages. Am I missing something basic?
Ok, I've updated instructions:
*Launch your Anaconda CMD as Admin
#if tensorflow virtual env has been created, remove it first
conda remove --name tensorflow --all
conda create -n tensorflow --python=3.5 anaconda
activate tensorflow
conda install spyder
conda install ipython
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.1-cp35-cp35m-win_amd64.whl
spyder
Tensorflow on windows only works with Python 3.5 64-bit version, I don't know why doesn't work with Python > 3.5. Try this
conda create --name newEnv python=3.5
activate newEnv
(newEnv)C:> pip install tensorflow
This install Tensorflow in that particular environment. For testing run
(newEnv)C:> python
>>>import tensorflow as tf
>>>hello = tf.constant('Hello Tensorflow!')
>>>sess = tf.Session()
>>>sess.run(hello)
It should run without any error with output "Hello Tensorflow). Tested it on Windows 10 with python 3.5 64-bit and installed tensorflow 1.0.1 cpu version.
For Windows 10 (With NVidia 840M GPU)
If you have a different GPU check here to make sure your Compute number is > 3.0. My GPU has a 5.0
Mostly following instructions from official install instructions and steps from Stack Overflow Answer
I have found most answers do not combine the full installation from a clean install.
Configure the machine first
Download and install Anaconda from Download Anaconda-Windows Link
Installed Anaconda as User (I did not test installing as admin)
Download cuDNN v5.1 (Jan 20, 2017), for CUDA 8.0
Requires entering your email address and signing up.
Unzip this folder and add the */cuda/bin folder to your %PATH%
Install NVIDIA Cuda Version 8 for Windows 10
Also ensure this is in your path
Check for missing DLL: if where MSVCP140.DLL returns nothing you may need to either add it to the path or find it here
Open Anaconda CMD (with admin privilages)
Now install using conda and to test the installation
In Anaconda CMD (using Admin):
conda create -n tensorflow python=3.5 anaconda
activate tensorflow
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.1-cp35-cp35m-win_amd64.whl
In Python:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
Also use the code in this answer to further confirm you are using the GPU

Installing a package in Conda environment, but only works in Python not iPython?

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.

Categories