英文:
Where to find spacy.py file to rename
问题
我正在尝试安装spacy,尝试了多种方法,包括使用pip
、conda
,以及直接从git安装。然而,我遇到了相同的错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[26], line 3
1 import spacy
----> 3 nlp = spacy.load("en_core_web_sm")
AttributeError: module 'spacy' has no attribute 'load'
从阅读诸如这篇文章之类的各种在线文章中,我看到我的错误可能是由一个名为“spacy.py”的文件引起的阴影错误。然而,我找不到这个文件。我觉得这可能是一个容易找到的东西,但迄今为止还没有找到
在我的目录中使用which python
显示:
/Users/my_name/anaconda3/bin/python
查看我的anaconda3/bin/python目录,我确实看到一个名为“spacy”的Unix可执行文件,但重命名它并没有解决我的错误。
英文:
I am attempting to install spacy and have tried a number of methods using pip
, conda
, and installing directing from git. However, I am running into the same error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[26], line 3
1 import spacy
----> 3 nlp = spacy.load("en_core_web_sm")
AttributeError: module 'spacy' has no attribute 'load'
From reading various articles online like this one, I see that my error is likely due to a file called "spacy.py" that is causing a shadowing error. However, I can't find this file. I feel like this is likely an easy thing to find but have yet to find it
Using which python
in my dir shows me:
/Users/my_name/anaconda3/bin/python
Looking into my anaconda3/bin/python dir, I do see a Unix Executable file named "spacy" but renaming it has not fixed my error.
答案1
得分: 1
确保您还安装了您喜欢的软件包:
对于pip:
python -m spacy download en_core_web_sm
此外,如果您在IDE中使用虚拟环境,您还应在安装spacy和您喜欢的软件包之前运行以下命令:
对于pip:
python -m venv .env
source .env/bin/activate
对于conda:
conda create -n venv
conda activate venv
您的环境之间也可能存在不匹配。如果您使用Anaconda,请尝试在Anaconda Powershell中安装spacy。否则,请尝试在IDE的终端中使用conda和/或pip安装spacy。
英文:
Make sure you're also installing your preferred package:
For pip:
python -m spacy download en_core_web_sm
Also, if you're using a virtual environment in your IDE, you should also run the following commands BEFORE installing spacy and your preferred package:
For pip:
python -m venv .env
source .env/bin/activate
For conda:
conda create -n venv
conda activate venv
There could also be a mismatch between your environments. If you're using Anaconda, try installing spacy in the Anaconda Powershell. Otherwise, try installing spacy using conda and/or pip in your IDE's terminal.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论