简体   繁体   中英

Installing libraries in Spyder (Anaconda)

I just recently uninstalled python and anaconda and reinstalled Anaconda3 only (I read that Anaconda installs python for you). I'm using Python 3.8.3 through Spyder in Anaconda3.

Previous to the reinstall, I never had issues with the pip and conda commands in spyder

Now I'm getting these errors:

runcell(0, 'C:/Users/user1/.spyder-py3/temp.py')
  File "C:\Users\user1\.spyder-py3\temp.py", line 9
    pip install fastai
        ^
SyntaxError: invalid syntax


runcell(0, 'C:/Users/user1/.spyder-py3/temp.py')
  File "C:\Users\user1\.spyder-py3\temp.py", line 8
    conda install -c fastai fastai

These posts have been unhelpful: Pip install in Spyder What is the difference between pip and conda?

Is there some simple solution for this? Eg when I installed Anaconda for the first time I never had these issues.

Based on your output, which says

runcell(0, 'C:/Users/user1/.spyder-py3/temp.py')

and this , it is evident that you are trying to run the

pip install fastai

inside a python script . The pip command is a command line command, pointing to certain pip.exe , and it should be ran from the command line (or, you may use the IPython shell of Spyder if you want). Therefore, just run the pip install command in the IPython console of Spyder (or a cmd prompt).


In IPython shell, it is also possible to install packages using the %pip magic :

%pip install fastai

You can also run operating system commands by adding ! before your command. For example

!pip install fastai

Edit: Although, seems that pip works in my IPython shell with or without the % or ! .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM