1

Sorry, I am very new to Python, this may be a silly question.

I have installed Anaconda on Mac, and have been using basis libraries like pandas. When I try to install oauthlib library by using : pip install oauthlib, on Ipython, I get the error : pip can be only installed outside Ipython. Now I go to mac terminal, run pip3 install oauthlib, it seem to have installed it. However when I run my code from spyder(in anaconda). I get error no module name 'oauthlib'

What's going on here ? Is my code running in anaconda, and there's another python software installed ?

Yeshwanth N
  • 570
  • 4
  • 15
Avi
  • 11
  • 2

3 Answers3

1

Make sure you're installing oauthlib in the conda environment you're using for your project. Do the following in the terminal:

  1. First create the environment: conda create --name myenv
  2. Next, activate the environment: conda activate myenv
  3. Last, install oauth: pip3 install oauthlib

Then just make sure your IDE is using the proper conda environment. Good luck!

BLimitless
  • 2,060
  • 5
  • 17
  • 32
0

Anaconda works like a containerized environment (virtual environment) which maintains it's own version of libraries and python version installed.

If you installed a python library on the Mac/Linux terminal (without running 'conda activate base'), it then installs it to the native version of python installed on Mac, not on Anaconda.

If you wish to run the code on your local/Mac version of Python go to the terminal and type:

pip install oauthlib

And then run the python code on the terminal itself without switching to Anaconda(since Anaconda seems to be giving an error)

In-case the command 'conda' doesn't work, running conda init and closing and opening the terminal again should do the trick.

In-case it doesn't work you need to figure out the SHELL the terminal is running on using:

echo $(which SHELL)

Output should be something like this

/usr/bin/zsh

If it's zsh then place this into your following zshrc and if it's bash then it's bashrc present in the home directory.

nano ~/.zshrc
or
nano ~/.bashrc

And paste this to the end of the file

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/bitsage/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/bitsage/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/bitsage/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/bitsage/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
C Rishi
  • 216
  • 1
  • 5
  • Thanks for your answer. I tried conda activate base on the termina, but it can't identify the conda command. Command not found. Is there another way I can installs the libary in Anaconda ? – Avi May 13 '21 at 13:55
  • I have edited the response, have a look and ping me back for any other issues which might pop-up. – C Rishi May 13 '21 at 14:41
  • 1
    @avishek pal you should be in the habit of installing any packages like oauth in your non-base environment so you don't get a mess of dependencies. See second answer for how to do this. – BLimitless May 13 '21 at 22:40
0

It should be already installed if you are using a mac... If not, try writing this in your command prompt:

python get-pip.py
CodeBox
  • 1
  • 2
  • Thanks for your response. I want to install the libary in anacaonda. Do you suggest any way to do that ? – Avi May 13 '21 at 13:57
  • Hey @Avishek Pal, see the below answer for how to install the library in a conda environment. – BLimitless May 13 '21 at 21:11