Reputation: 21
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 ?
Upvotes: 1
Views: 888
Reputation: 2575
Make sure you're installing oauthlib in the conda environment you're using for your project. Do the following in the terminal:
conda create --name myenv
conda activate myenv
pip3 install oauthlib
Then just make sure your IDE is using the proper conda environment. Good luck!
Upvotes: 1
Reputation: 226
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 <<<
Upvotes: 0
Reputation: 1
It should be already installed if you are using a mac... If not, try writing this in your command prompt:
python get-pip.py
Upvotes: 0