ModuleNotFoundError for Tensorflow and Anaconda (Windows 10) - python

I can't get tensorflow to work on two different Windows PCs and on both I get "ModuleNotFoundError: No module named 'tensorflow' when try to import them in python.
Numpy for example works on one machine not the other. Checked a dozen of posts on stackoverflow, nothing really helps. Clearly somethings wrong with the paths, can't really figure out what and how to trouble check it. I followed this set-up https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Installation-Windows.md
I need the 1.7.1 version of TF for Unity ML-agents to work
OS: windows 10
conda version : 4.4.11
conda-build version : 3.4.1
python version : 3.6.4.final.0
Even a clean install of Anaconda didn't help.

I finally managed to fix this (not with ML-agents, but that's a different story). I uninstalled Anaconda and Python as well as cleared the registry from all Python information. I had a previous installation of Python 3.7 and I'm guessing this might have caused some issues. Clean install of Anaconda with a 3.6 env and TF is working both with cpu and gpu support.

These problems often happen when you are on the wrong environment, or when you do not activate your environment. Please try the following steps and see if the problem persists:
Open Anaconda prompt
Activate the environment in which you installed tensorflow by using conda activate YOUR_ENV_NAME
Type python to launch python
try to import tensorflow
And see if the error persists.

Related

Installing Pipetorch in Spyder 5.3 Python 3.8.10

I have tried many times to install Pipetorch in Spyder 5.3 with Python 3.8.10, but it failed.
I have tried as well conda as pip commands, but it does not work. If I use %pip I get this:
Note: you may need to restart the kernel to use updated packages. C:\Users\szewa\AppData\Local\Programs\Spyder\Python\python.exe: No module named pip
If I use conda I get this:
`ValueError: The python kernel does not appear to be a conda environment. Please use ``%pip install instead.`
Can someone help me? I can find nothing on internet that works...
You seem to be confused about the differences between pip and conda. Anyhow, your Python installation is messed up now and only a restart will help now.
The easiest way to use Python together with the Spyder IDE is to install Anaconda and learn some conda basics: Getting started with conda.
If you really want to install Spyder with standard Python, follow the recipe from Spyder installation without Anaconda, but it seems to be tricky.

Why do I get an error trying to use keras package in R?

I'm trying to run through an example for building a neural network in R. I tried following the instructions at https://opendatascience.com/using-keras-and-tensorflow-in-r/.
I've installed the keras and tensorflow packages and I have the anaconda navigator downloaded on my laptop. When I run the following:
library(keras)
library(tensorflow)
reticulate::use_condaenv(“r-reticulate”)
mnist <- dataset_mnist()
I'm getting this error
Error in conda_python(envpath, conda = miniconda) :
no conda environment exists at path 'C:/Users/smurphy4/AppData/Local/r-miniconda/envs/r-reticulate'
This is probably a stupid question but I haven't used python before and I only have a little experience with R and would really appreciate any help.
Also, I don't know if this is relevant but when I open the anaconda navigator and look in environments, there isn't an r-reticulate environment, only a base (root) environment.Anaconda navigator environments
In case anyone has a similar problem, I just uninstalled Rstudio and installed again through a new python environment in anaconda navigator and installed the modules I needed in that environment. That seemed to work.

Keras/Tensorflow in RStudio not referencing Python in Miniconda Environment

so I've been trying to use Keras with Miniconda on my machine for a few weeks now (in Rstudio) and I've still been unable to make significant progress.
Most recently, here are the steps I followed:
create an environment in Miniconda, using Python 3.6
Download R and RStudio (an older version, Version 3.6.0) into said environment and run them
Install Keras into the environment (after Rcpp, Devtools etc)
Attempt to install Tensorflow
But then I get the error message that my Python installation isn't found and the bindings aren't loaded.
I've put the environment on the PATH, as well as the location where Python is and some folders within the environment.
I followed the advice given in a comment in my last post, which helped me to create the environment, but now Python isn't loading in Miniconda and I'm so so frustrated that I haven't been able to make this work. Please help.
When I look for the Python version I get this:
C:\Users\NK>python --version [1] Python 3.8.4rc1
Here is the beginning of the code I'm running:
library(keras)
library(tensorflow)
library(reticulate)
use_python("C:\\Users\\NK\\AppData\\Local\\Microsoft\\WindowsApps", required=T)
Sys.setenv(RETICULATE_MINICONDA_PATH = "C:/mini/envs/r_3.6.0.1")
mnist <- dataset_mnist()
and I get this error:
Error: Installation of Python not found, Python bindings not loaded. Use reticulate::install_miniconda() if you'd like to install a Miniconda Python environment. even though I'm doing this entirely in a Miniconda environment. I'm even opening RStudio straight from the Miniconda command prompt.
Some basic info: Dell XPS 15 running Windows 10, using RStudio
Side question: Is there an easier way to do all this? It's been fatiguing.
I finally got it to work! Here were my steps for anyone who stumbles across this:
Reinstall Anaconda
Create Anaconda Environment with Python 2.7 and R
Install Keras and Tensorflow packages and dependencies one by one into the environment through Anaconda
Install RStudio in the environment through Anaconda
use use_python("[env]", required=T) and Sys.setenv(RETICULATE_MINICONDA_PATH = "[env]") in any scripts you run using Keras

Getting CondaVerificationError when installing tensorflow(windows 10)

I got error message when I am trying to setup tensorflow.
I examine a lot of discussion from github issues. I tried different versions but output doesn't change.
I saw this previous question in stackoverflow too but there is no answer avaliable.
I am trying to be more specific about error and platforms I am currently using and I hope someone help me or show me different approaches.
First of all I had python 3.6.x
but I deleted this version cause I want to make this setup clearly.
I downloaded Anaconda (Anaconda Python 3.7 version)
After that I checked my python version and its changed like 3.7 as I expected.
After that I follow the guide for setup tensorflow
conda create -n tf-gpu tensorflow-gpu
Because I want to use my gpu which is much faster comparing with CPU
(I already checked my gpu compability for tensorflow,I am currently using rtx 2060)
Summary:
-Anaconda Python 3.7 version
-Python 3.7.4
I solved my problem about insalling tensorflow maybe it will help other people.
Firstly, I just cleared my PATH under the Environment Variable which are related with Anaconda or you can delete Anaconda and reinstall.
After that open Anaconda command line and write:
pip install tensorflow-gpu

Importing Numpy results in error even though Anaconda says it's installed?

I signed up for a statistics udemy course which uses jupyter running the stock numpy package out of anaconda.
Numpy is working when I run python 3.4.4 in pycharm, but it will not work in either anaconda2 nor anaconda3.. this makes no sense because numpy comes stock as part of the anaconda library.
When I try importing numpy in jupyter, running a local instance of a python 2 script, I get this:
Thinking I could sidestep the error using a IDE, I tried pycharm and I got this:
Numpy is part of the anaconda default library which I'm running, so I checked and made sure the numpy package was there via the Anaconda Prompt using 'conda list'...
Why won't it import successfully?
Before I uninstall and reinstall everything, does anyone have any ideas?
Yayyyy. I figured it out. So I had several different python versions before I was running python through anaconda/jupyter. As a result, the tethering in-between the additional package libraries to the version of python running was shifty. For example, I may have had numpy working configured to 3.4 but not 2.7..
anyways, to break down the steps I took, I uninstalled all instances of python (both anaconda and normal versions). Then I deleted the old 3.4 libraries from my C drive. Then I installed anaconda 2.7.11 again, tested importing numpy and got the same error. Then I thought to myself, what if the packages are installed separate from the python library and their configuration didn't get reset via the reinstall.. so via the anaconda prompt I typed:
pip uninstall numpy
which removed the package I was having trouble with. and then :
pip install numpy
which downloaded and reset a whole new instance of the package. Then I tested importing numpy in both the anaconda prompt and jupyter = both worked.
I'm very happy that this ended up working out as I can continue on as planned. For anyone else who experiences a similar problem, I would try uninstalling, then reinstalling the problem causing package via pip commands - this step seemed to have the most impact on fixing the problem. Then if that doesn't work proceed to uninstall and reinstall the environments in intervals.
You can try using the following command:
pip install numpy --upgrade
This will uninstall old installed version of numpy and install a new version. This command solved my issue.
try activating you base conda environment before starting jupyter.
>activate root
>jupyter notebook

Categories

Resources