Unable to create process because python.exe & pythonw.exe under Conda environment MISSING/GONE - tensorflow

From [Anaconda installer archive], I install Anaconda3-4.2.0-Windows-x86_64.exe, I open a conda prompt. I create conda environment.
conda create -n keras_tensorflow_2 python=3.5
Activate it.
activate keras_tensorflow_2
Install Theano, Tensorflow & Keras.
conda install theano
pip install --ignore-installed --upgrade tensorflow
pip install keras
*Although here, theano is successfully installed but does not work. But that's a different matter.
Run python & test for tensorflow inside the conda prompt.
python
import tensorflow
No error. It works.
So now I want to open using Spyder.
If I directly open Spyder, and import tensorflow inside the IPython, error shows:
ImportError: No module named tensorflow
So what I did that work is
Open Anaconda Navigator
Anaconda Navigator>Environments. Click keras_tensorflow_2 environment. [Pic_1]
Anaconda Navigator>Home. At dropdown menu for "Applications on", choose tensorflow_2. Install Spyder. [Pic_2]
Then, open Spyder from Start Menu. Windows Security Alert pop up. Click Allow access. [Pic_3] . Test tensorflow, still not working.
So have to go back to Conda Prompt. Type
activate tensorflow_2
spyder
Conda prompt will automatically close and Spyder will automatically open. Import Tensorflow. Finally WORKS!
Up until this point, the folder Anaconda3>envs>tensorflow_2 still has python.exe and pythonw.exe as show here [Pic_4].
HOWEVER, once I close/restart Spyder, the folder Anaconda3>envs>tensorflow_2automatically has MISSING python.exe and pythonw.exe. [Pic_5] I don't know why this would happen. So I can no longer use this environment. When I tried to 'Open with IPython' through anaconda navigator [Pic_1], error:
Unable to create process using
'C:\Anaconda3\envs\keras_tensorflow_2\python.exe
C:\Anaconda3\envs\keras_tensorflow_2\Scripts\ipython-script.py -i'
And every time I want to use Tensorflow, I have to recreate the environment. Any advice please? Thank you.
All pictures available here: https://drive.google.com/open?id=0B6eS8bjSwwBLSzFRTFVHdG9zTTA

I found a way around it. Python.exe and Pythonw.exe still missing. Maybe it actually doesn't matter them being missing. I don't know.
Anyway, when inside conda prompt, if I navigate to my specific environment's Script, activate the environment and then run Spyder from there, it will work.
cd C:\Anaconda3\envs\keras_tensorflow_2\Scripts
activate keras_tensorflow_2
spyder
Reference: How to ensure that Spyder runs within a conda environment?

Related

Spyder can't load tensorflow in conda environment although python can

I created a conda environment including Spyder and tensorflow in the dependencies and all installs went without errors.
When I activate the environment and launch python, I can import tensorflow and run code without any issues.
However when launching spyder from within the environment (Spyder shows on the bottom of the GUI that is part of that conda environment), and load tensorflow, it throws an error:
ModuleNotFoundError: No module named 'tensorflow_core.estimator'
and from then the Console gets stuck repeating the same error.
Why does spyder have issues importing a module that python in the same environment can import? How can I fix this?
I have tried re-installing spyder in the conda environment but the same issue prevails.
Try to uninstall tensorflow-estimator pip uninstall tensorflow-estimator and uninstall Tensorflow.
#After fresh installing tensorflow
pip install tensorflow
#Install tensorflow_estimator
pip install -U tensorflow_estimator
Try this workaround as well.

import tensorflow working in terminal but not in jupyter notebook

I used the following guide to install tensorflow-gpu - https://towardsdatascience.com/tensorflow-gpu-installation-made-easy-use-conda-instead-of-pip-52e5249374bc
I created a new environment and installed tensorflow-gpu using the command -
conda create --name tf_gpu tensorflow-gpu
If I activate the environment, start python in terminal, and import tensorflow from the terminal, it works.
BUT
When I activate the environment, run a jupyter notebook and type -
import tensorflow
I get module not found error. How do I resolve this?
Start Command Promt (CMD) as administrator (right click). Do not enter any environment yet.
Install Jupyter (and nb_conda as well as ipykernel) to get your environments listed: conda install jupyter nb_conda ipykernel
Activate the environment you want to add to jupyter kernel: conda activate myenv
Install ipykernel in the environment (do this for all envvironemnts you would like to add): conda install ipykernel
To start Jupyter, cd to root (cd .. until you are at C:) then type (does not need to be inside and env): Jupyter noteboook
You might need to confirm that it shall open in a web browser (I use chrome)
Once open in a browser navigate to the folder of your choice, then make a new python 3 file.
Once inside click Kernel -> Change kernel and select the conda env you would like
You should now be able to change kernel (env) within all conda environments that have ipykernel installed (step 4)

How do you install a module in spyder anaconda?

I'm trying to run some code in Spyder Anaconda. I thought it would be as simple as importing it as seen in the code but I get an error message:
ModuleNotFoundError: No module named 'image_registration'
I know this means that image_registration isn't included in what Spyder already has but I cant quite figure out how to add it.
from image_registration import chi2_shift
from image_registration.fft_tools import shift
Add your Anaconda Scripts path (Default=C:\Users\userna**\Anaconda3\Scripts) to Environment Variables and open your command prompt and type
pip.exe install module_nameIn your case pip.exe install image_registration To install module image Registration
Please tryout the below steps in anaconda prompt
1. conda create -n myenv
2. activate myenv
3. pip install image_registration
4. conda install spyder
5. spyder
If you have already installed image_registration package in an environment you can activate that environment and try to open spyder from the activated environment.

Anaconda prompt crashes as soon as I activate tensorflow env

I have just installed Anaconda 3.7 in Windows 10. Then I have created a new env for
tensorflow and installed it there. It got installed without any problem. Then I
used the command
conda install -c conda-forge keras
to install Keras. While Keras installation was running, Anaconda Prompt crashed suddenly. I restarted it and I tried to activate my tensorflow env; but as soon as I try to activate it, Anaconda Prompt crashes!! Please take a look at my screenshot. How can I fix this? Thank you very much for your support.
Ferari
Anaconda Prompt Crashes
The problem could be due to the version of tensorflow - tensorboard mismatch. When you give the command conda install -c conda-forge keras for installing keras, the tensorflow and tensorboard versions gets changed.
I tried the following steps and it worked fine for me.
conda create -n tf python=3.6
activate tf
conda install keras
Installing keras will automatically install tensorflow.
I just had an issue with the same symptom. Instead of printing the error message, the activation of the conda environment exited the console application.
The scripts that run on activation can be found in ./etc/conda/activate.d inside the environment. The path to the environments can be found using conda env list. Check these scripts for any 'exit' commands, commenting them out if necessary. This should let you at least see the error message.
In my case the issue was caused by packages requiring MSVC compiler, and Visual Studio studio was not installed.
I was also facing the same error and i have resolved it by re creating the conda environment. It is happening due to version mismatch between couple of packages. Just delete the conda environment and re-create the environment but this time do not add tensorflow GPU package instead just add keras-gpu, it will take care everything.
I did the following things:
deleted the same env
created the same environment using
conda create -n myEnv python==3.6
install keras gpu
conda install -c conda-forge keras-gpu
now it will install necessary packages and then you can activate the environment and use it
I encountered the same problem. Solved by creating a new env and using
conda install -c hesi_m keras
This will install the latest versions of Keras and Tensorflow.
Turns out you will most likely get an outdated version of keras if you installed it with conda install -c conda-forge keras.
Same problem here..
I just have installed tensorflow-gpu in tf-gpu environment using
conda install tensorflow-gpu
It has successfully installed and works perfectly. But after installation whenever I am going to use environment by this command
activate tf-gpu
it shows the followingenter image description here output and close the command prompt soon. I am using anaconda for python 3.6.
when you open Anaconda command prompt just press ctrl+c and press Y to avoid the crash for now and then start again with the task of setting the environment for tensorflow...
this worked for me..

How to install tensorflow with Conda

I have been trying to install tensorflow via Conda for a couple days now with no luck.
I made a fresh install of anaconda3/miniconda3 followed the steps to fix the .bash_profile issue. Then
$ conda create -n tensorflow pip python=3.6
seems to work. However
$ source activate tensorflow
does nothing. I tried conda activate tensorflow and nothing. If I type conda info I can see that the tensorflow env is running. But I have no ability to type within it?
Welcome to Python and Tensorflow.
This bit really takes a long time to figure out unless somebody told you how to do so.
Follow this. Assume you installed Miniconda (then python is automatically installed) and you are using linux (cuz you mentioned 'source')
You want to make an conda environment named 'ai3' and you wanna install many packages like tensorflow within 'ai3' env.
In your command line,
1) Create ai3 env: see https://conda.io/docs/user-guide/tasks/manage-environments.html for details
$ conda create -n ai3 python=3.6
2) Log your current command window into the ai3 env
$ source activate ai3
3) Install packages, for example tensorflow: details in https://www.tensorflow.org/install/install_linux but that does not really help FOBs
$ pip install tensorflow
4) Enter yes whenever your command window asks sth. Once it's done, then you wish to use tensorflow (TF) in python. Do this
$ python
$ >> import tensorflow as tf
$ >> hello = tf.constant('Hello, TensorFlow!')
$ >> with tf.Session() as sess:
$ >> sess.run(hello)
4-1-0) Obviously you don't wanna do this all the time. Download Pycharm community edition (in https://www.jetbrains.com/pycharm/download/#section=linux) and install.
4-1-1) Create a new project in any location you like with interpreter 'ai3'. Interpreter is the env you just prepared in step 1,2,3): click 'add local' by clicking a button at the right end of the 'Interpreter' line -> a python file at '/miniconda3/envs/ai3/bin/python'
5) Now work with many tutorials out there on this setup
First you need to check the naming convention you are using. I know that's how documentation suggests, but I think it's misleading.
Name your environment according to what you want to be doing inside of it. Tensorflow is a package (that can be a python package) that you will use inside of the environment so you can name it something like:
$ conda create --name 'machinelearning-env' pip python=3.6
Also if you just installed Anaconda you do not need to specify the python designation.
Then you need to activate your environment with
source activate (whatever you named your conda env)
Next you can install with :
:~/anaconda3/envs$ pip install --ignore-installed --upgrade (the tensorflow url found here: https://www.tensorflow.org/install/install_linux#the_url_of_the_tensorflow_python_package )
Finally instantiate python and then you can import tensorflow with :
import tensorflow as tf
I suggest you refer back to the tensorflow documentation as it's all there. Good luck!
You should first give a name to your environment then give package names that you want to install ie.
conda create -n tensorflow_env tensorflow
Easiest way for me at least.