简体   繁体   English

在 Spyder (Anaconda) 中安装库

[英]Installing libraries in Spyder (Anaconda)

I just recently uninstalled python and anaconda and reinstalled Anaconda3 only (I read that Anaconda installs python for you).我最近刚刚卸载了 python 和 anaconda 并仅重新安装了 Anaconda3(我读到 Anaconda 为您安装 Z23EEEB4347BDD2755BDDZFC6) I'm using Python 3.8.3 through Spyder in Anaconda3.我在 Anaconda3 中通过 Spyder 使用 Python 3.8.3。

Previous to the reinstall, I never had issues with the pip and conda commands in spyder在重新安装之前,我从未遇到过 spyder 中的pipconda命令的问题

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?这些帖子没有帮助: Pip install in Spyder pip 和 conda 有什么区别?

Is there some simple solution for this?有一些简单的解决方案吗? Eg when I installed Anaconda for the first time I never had these issues.例如,当我第一次安装 Anaconda 时,我从未遇到过这些问题。

Based on your output, which says根据您的 output,它说

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 .在 python 脚本中。 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). pip命令是一个命令行命令,指向某个pip.exe ,它应该从命令行运行(或者,如果你愿意,你可以使用 IPython Z2591C98B70119FE6248Z8B1E424Bpyder9)。 Therefore, just run the pip install command in the IPython console of Spyder (or a cmd prompt).因此,只需在 Spyder 的 IPython 控制台(或 cmd 提示符)中运行pip install命令。


In IPython shell, it is also possible to install packages using the %pip magic :在 IPython shell 中,也可以使用%pip魔法安装包:

%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 !编辑:虽然,似乎 pip 在我的 IPython shell 中使用或不使用%! . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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