How do you install a module in spyder anaconda? - module

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.

Related

ModuleNotFoundError: No module named 'tensorflow' error in vscode terminal while running fine in wsl

I installed tensorflow using conda in wsl, and now I'm using it through Jupyter notebook and it's working fine. I also write codes in vscode and then run it through wsl using python3 filename.py and it works fine too.
the problem is when I try to run the code using the 'running' option of vscode and then I get the error ModuleNotFoundError: No module named 'tensorflow' in terminal.
I checked my environments and I only have 'base' environment so the packages should be installed there and I also tried 'conda ...' in vscode terminal and it didn't recognize conda either.
what can be the problem with my vscode?
also I have to say that numpy and matplotlib packages are running fine using vscode itself but tensorflow and some other modules are not identified
You need to create a new virtual environment in anaconda to install Tensorflow and can access the Visual Studio code from the same virtual environment.
Open anaconda prompt and type below code to create virtual environment
conda create -n tf tensorflow
conda activate tf
install TensorFlow in that "tf" virtual environment
pip install tensorflow
launch VS code by selecting the same "tf" virtual environment in anaconda navigator.
Now, type the below code to check if TensorFlow installed successfully in VS code.
import tensorflow as tf
print(tf.__version__)
Likewise, you can install other required packages in the same virtual environment.
pip install <package-name>

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)

ImportError: Missing required dependencies ['numpy'] from Pandas Created Conda Environment

I created a new conda environment as follows
conda create -n NAME python=3.5
Added edit, of course activate the environment like so
activate NAME
Installed these libraries all at once
conda install numpy scipy pandas scikit-learn jupyter matplotlib
relevant libary versions that conda installed
when importing pandas ge
ImportError: Missing required dependencies ['numpy']
Can anyone replicate this installation of env on windows? I am thinking one of the files version are causing this and cannot find a solution, barring an externality.
Have uninstalled and installed pandas, numpy, etc all libraries, have also tried installing with pip even, nothing is working. Have even created another environment from scratch same error is occurring.
Conda should have installed a number of libraries when you build python 3.5 in the new environment. If you run "conda list" in the command line of the newly built environment it will show the packages you have by default. Try to build the environment with "conda create -n py35 python=3.5 anaconda" so it uses the anaconda python and will auto install packages.

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

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?