I just installed PyTorch after installing Anaconda, and when I run iPython using Anaconda Python, it won't find PyTorch.
However I can verify PyTorch is in the pkgs directory of my anaconda folder.
What's going on?
While the framework name is Pytorch, it must be imported using the torch namespace like so import torch. If you look at the official documentation here, you will see any pytorch related module import like nn or autograd is done through the torch namespace. I admit it is a bit confusing but I guess it was done to instill a sense of familiarity for old torch7 users. Also, there is a very good introduction tutorial which you could probably use to familiarize yourself better with the ins and outs of pytorch found here. Hope this helps!
The Py Torch package might have installed to a different python environment that you might have on your system.
You can see the entire list of python packages installed in your current environment using
pip freeze
Ensure that the pip command being executed belongs to Anaconda distribution. The following command will provide the path of the pip executable.
which pip
Related
I'm a little confused with package install in anaconda environment.
I can install my python packagse in the following ways.
open anaconda prompt and do : conda install tensorflow
launch an jupyter notebook from anaconda prompt, choose the default python kernel, and do:
!pip install tensorflow
Can someone tell me what is the difference between these two cases? Where are the python packages installed? What happens when I pip install python packages in default kernel in jupyter notebook?
I was able to install tensorflow in jupyter notebook in default kernel (python3), but trying to import tensorflow give me module note found error. Does anyone know why that happened? What is happening under the hood? Very much appreciate any help to clarification.
pip is the default package manager that ships with python. Conda is also a package manager, but it is third party. Conda was made especially for data science libraries. Libraries installed with conda usually give much better performance than pip. In pip, the packages are stored in python/scripts and conda stores them at /anaconda/pkgs/. As for the module not found error. I would need more information about it, but you can check out this video. I learnt how to install TensorFlow here and would highly recommend it.
I want to ask that I face the problem:
ModuleNotFoundError: No module named 'skimage'
even though I have already pip3 install scikit-image.
1
my version is Python 3.7.2
and when typing pip3 list, the version is:
scikit-image 0.17.2
Does any one know how to solve this problem?
Thank you very much
scikit-image and scikit-learn are two different packages. The latest scikit-image version is 0.17.2. Are you sure you have installed scikit-image?
It also depends wether you are on a Anaconda plateform or a local python platform in your computer (c:\User....). If python is installed directly in your computer outside Anaconda, this error may occur when importing the scikit-image library. In such case, you should re-install the scikit-image library from the Anaconda plateform by typing the command 'conda install scikit-image' from the Ananconda prompt or terminal.
I am trying to import tensorflow_datasets to load a data set, but I found that I should install tensorflow_datasets using either pip or conda. I installed it twice using both methods. But tensorflow_datasets do not still work in jupyter notebook. In the last attempt I got the following error:
ImportError: cannot import name 'kwarg_only' from 'tensorflow.python.util.tf_export'
Plus
Failed to import TensorFlow. Please note that TensorFlow is not installed by default when you install TensorFlow Datasets. This is so that users can decide whether to install the GPU-enabled TensorFlow package. To use TensorFlow Datasets, please install the most recent version of TensorFlow, by following instructions at https://tensorflow.org/install.
While I have TensorFlow installed. I searched the net but none of the solutions solved the problem. Any help is appreciated.
Try to create a separate environment and then install tensorflow and tensorflow_datasets using pip install tensorflow==2.0.0 and pip install tensorflow_datasets==2.1.0. Its works fine.
after following the instruction in http://docs.h2o.ai/h2o/latest-stable/h2o-docs/downloading.html#install-in-python, I was able to install h2o v 3.16.0.2. I was also able to use command line instructions mentioned in the above website and test that it is working.
python
import h2o
h2o.init()
h2o.demo("glm")
However, when I launch anaconda spyder, I am not able to import h2o. How do I link the h2o I have installed and bring it into Spyder python?
Update:
I have already tried {conda install -c anaconda h2o } which is mentioned on Anaconda.org, but that installs older ver 3.10 of h2o and that did not work either.
thanks for your help.
I believe the problem is due to your python environment. When you install Anaconda, you need to use anaconda pip, to ensure that the installed packages are available in conda.
The short answer is you can install the lastest stable version of H2O (3.16.0.2 as of today) using conda via h2oai channel instead of anaconda channel (h2o maintains it's own channel):
conda install -c h2oai h2o
this should solve your issue.
But more generally, the packages will appear in conda if you use anaconda pip. You can check which pip is being used by doing
which pip
and making sure that the path to the pip is within your anaconda distribution; something like /home/<userdir>/anaconda/bin/pip instead of /usr/bin/pip
Same is true also for Python. Try checking if starting Python in terminal points to anaconda Python by doing which python. If that's not the case, than you would need to add the conda installation of Python to your PATH variable. Please refer to conda docs for instructions https://conda.io/docs/user-guide/install/index.html
It would have been helpful if you had included information regarding your operating system in the question.
I already have Python 2.7 installed but I wanted to try IPython so I installed IPython via Anaconda as recommended on the ipython website (although not sure what the pros/cons of doing this are). Now I would like to use ipdb debugger. I guess I need to make sure it installs underneath the Anaconda version of python rather than the normal python.
How do I install this? In general if I want to install some arbitrary python module under Anaconda how do I do this?
Actually I think in the case of ipdb it's already installed with Anaconda. But in general it appears you can just install stuff via either pip or easy_install as necessary. The key that I was missing is to make sure you are using the pip/easy_install that comes with Anaconda (which are .bat files in the Scripts directory) rather than the system Python's pip/easy_install. So:
Anaconda\Scripts\easy_install somepackage
This will install somepackage in Anaconda\lib\site-packages\ and not in the system python. This appears to work and I can now import somepackage from my anaconda python. This seems to work. It wasn't clear to me from reading Anaconda documentation if everything needed to be in a conda package or not.
This answer seems to support this idea: Installing Anaconda into a Virtual Environment
Generally the first thing to check is whether someone else has already built it for your version of python and uploaded it to anaconda.org:
anaconda search -t conda ipdb
then find a repository with ipdb built for your OS, and try
conda install -c <repository> ipdb
e.g. conda install -c conda-forge ipdb
You might need to try a few different ones to find one built for your version of python. There is a feature request to make this easier.
If that doesn't work, then pip install ipdb will