Anaconda does not recognize: xgboost, catboost and lightgbm - python

So I have already installed all these packages.
But I cannot import them. Anaconda gives me the error: "No module named..."
# conda install -c conda-forge xgboost
import xgboost
# conda install -c conda-forge catboost
import catboost
# conda install -c conda-forge lightgbm
import lightgbm as lgb
I have looked all over the internet, no solutions work. I cannot import the packages.

Try create its own environment:
conda create -n boost python=3.6
Then activate it and install your packages there:
conda activate boost
conda install -c conda-forge spyder xgboost catboost lightgbm
In the environment type:
spyder
And happy coding

(Spyder maintainer here) To solve this problem you need to:
Create a conda env to install all packages that come from conda-forge. That's because conda-forge packages are binary incompatible with the default packages provided by Anaconda.
Read our guide to understand how to connect Spyder to different Python environments.

Related

Installing GeoPandas on Spyder 5.1.5

Since updating Spyder to version 5.1.5, I'm unable to install GeoPandas. I've tried the following:
conda install geopandas
conda install --channel conda-forge geopandas
conda install -c conda-forge geopandas
and
conda create -n geo_env
conda activate geo_env
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
conda install python=3 geopandas
and none seem to work. I've also installed all the necessary dependencies, with the exception of Fiona (which returns the same installation problem).
After some research and a helpful post, I figured out a solution. There must have been an error when I previously updated Spyder to 5.1.5, and even though I had uninstalled and reinstalled Anaconda a number of times, GeoPandas wouldn't install until I removed Spyder through the Anaconda Prompt.
conda remove spyder
conda remove python-language-server (may return error but not a problem)
conda update anaconda (may return error but not a problem)
conda install spyder=5.1.5
conda install pandas
conda install geopandas
conda install openpyxl (had to reinstall)

Unable to install np_utils using conda

While installing 'np_utils' through conda, using the below command:
conda install -c auto np_utils
The below error appears:
RemoveError: 'pyopenssl' is a dependency of conda and cannot be removed from conda's operating environment.
RemoveError: 'setuptools' is a dependency of conda and cannot be removed from conda's operating environment.
Also tried installing 'setuptools' and 'pyopenssl' using conda, which results in the same error.
Moreover, 'setuptools' and 'pyopenssl' does not exist, which has been observed by using conda list.
You can try this before the installation
conda update --force conda
Try running Anaconda Prompt as an Administrator, then run this:
conda install -c conda-forge np_utils
It worked for me.
Here is the source: https://anaconda.org/conda-forge/np_utils

How to install pytorch in Anaconda with conda or pip?

I am trying to install pytorch in Anaconda to work with Python 3.5 in Windows. Following the instructions in pytorch.org I introduced the following code in Anaconda:
pip3 install torch torchvision
But the following error came in:
Command "python setup.py egg_info" failed with error code 1 in C:\Users\sluis\AppData\Local\Temp\pip-install-qmrvz7b9\torch\
By searching on the web I found out that it may be because of setuptools being out of date but I checked and have it updated. I also tried:
conda install -c peterjc123 pytorch cuda80
But the following error arise:
The following specifications were found to be in conflict:
- pytorch
Use "conda info <package>" to see the dependencies for each package.
I also tried to load the pytorch's tar.bz2 file which I download in the following website:
anaconda.org/peterjc123/pytorch/files
And then just do:
$ conda install filename.tar.bz2
But I got the following error:
Error: HTTPError: 404 Client Error: None for url: file:///C|/Users/sluis/pytorch-0.3.1-py36_cuda80_cudnn6he774522_2.tar.bz2: file:///C|/Users/sluis/pytorch-0.3.1-py36_cuda80_cudnn6he774522_2.tar.bz2
I am quite new to this programming world so I don't really know how to dig more on the errors. Anyone knows how to get pytorch installed?
Edit: As suggested in the comments I tried:
conda install pytorch torchivsion -c pytorch
And I got the following error:
Error: Packages missing in current win-64 channels:
- pytorch
- torchvision
I did:
anaconda search -t conda torchvision
And tried to install dericlk/torchvision using the following command:
conda install -c derickl torchvision
But I am getting the same error:
Error: Package missing in current win-64 channels:
- torchvision
I couldn't find any torchvisionpackages for win-64.
conda list is giving me the following:
# packages in environment at C:\Users\aaaa\AppData\Local\Continuum\Anaconda3\envs\torchenv2:
#
mkl-include 2018.0.2 1 anaconda
certifi 2016.2.28 py35_0
cffi 1.10.0 py35_0
cmake 3.6.3 vc14_0 [vc14]
openmp 2018.0.0 intel_8 intel
mkl 2017.0.3 0
numpy 1.13.1 py35_0
pip 10.0.0 <pip>
pip 9.0.1 py35_1
pycparser 2.18 py35_0
python 3.5.4 0
pyyaml 3.12 py35_0
setuptools 36.4.0 py35_1
typing 3.6.2 py35_0
vc 14 0
vs2015_runtime 14.0.25420 0
wheel 0.29.0 py35_0
wincertstore 0.2 py35_0
zlib 1.2.11 vc14_0 [vc14]
=======
Go to the official PyTorch.org and follow the steps accordingly.
Select your preferences and you will see an appropriate command below on the page.
If you don't have GPU in the system, set CUDA as None or CPU
Example command:
conda install pytorch-cpu torchvision-cpu -c pytorch
The following worked for me. First install MKL:
conda install -c anaconda mkl
After this, install pytorch and torchvision:
conda install -c pytorch pytorch torchvision
For windows python 3.6 and above without cuda
pip install torch==1.2.0+cpu torchvision==0.4.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
Can you please try with below steps
conda create -n pytorch_env python=3.5
source activate pytorch_env
conda install -c soumith pytorch
python
> import torch
You can even find pytorch after you execute command conda list.
For linux, cuda9.0, python3.6:
pip3 install http://download.pytorch.org/whl/cu90/torch-0.3.1-cp36-cp36m-linux_x86_64.whl
pip3 install torchvision
For other cuda/python version: check website: https://ptorch.com/news/145.html
try updating the base conda package with the following command,then you can try reistalling it.
conda update --all
conda update -n base conda
For me it worked doing this:
Uninstall the previous version: go to C:\users\username\anaconda3 and run the anaconda-uninstall.exe
Install again anaconda
then run the following commands on the anaconda pompt:
conda create -n my_env python=2.7
conda activate my_env
start the gui app
conda install -c peterjc123 pytorch
anaconda-navigator
For Readers live in 2021/06/xx:
use pip3 install torch
As an update, now the Pytorch official site has the right version depending on your system:
https://pytorch.org/
I recommend using the official website for installation. Some of the previous awnsers may lead to a version that is not adequate.
After Activating conda environment
Use below command
python3 -m pip install torch torchvision
Example
(torchenv) ubuntu#user :~$ python3 -m pip install torch torchvision
Visit https://anaconda.org/pytorch/torchvision and you will find the solution
conda install -c pytorch torchvision
Try running:
conda install -c pytorch pytorch

Installing Keras package with conda install

I have installed Anaconda package on a server as a user account, then I installed keras by conda install keras,but after installation, when I run import keras, it raised no module names keras,anyone can help? thanks very much!
One solution could be creating a conda environment:
conda create -n keras python=3.5
Now activate it:
conda activate keras
and install keras:
(keras)$ conda install keras
Try if it works:
(keras)$ python
>>> import keras
Once creating the Conda environment, use the command below to list available environment:
conda info -e
Once activate your conda environment, you can try to install Keras by
pip install keras==version_your_desired.
Then use
pip freeze
to check the version.

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