简体   繁体   English

Python 无法安装模块 spaCy

[英]Python Cannot install module spaCy

I´m new to python and I ran into a problem I can´t solve.我是 python 的新手,遇到了一个我无法解决的问题。 I would like to install and use the package spacy in python. Therefore I opened cmd and ran我想在 python 中安装和使用 package spacy。因此我打开 cmd 并运行

pip install spacy

While installing the dependecies I get an error message:安装依赖项时,我收到一条错误消息:

    ----------------------------------------

Command ""c:\users\xxx\appdata\local\programs\python\python37\python.exe" -u -c "import setuptools, tokenize;命令 ""c:\users\xxx\appdata\local\programs\python\python37\python.exe" -u -c "import setuptools, tokenize; file ='C:\Users\xxx\AppData\Local\Temp\pip-install-6vcdnb_4\numpy\setup.py';f=getattr(tokenize, 'open', open)( file );code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file , 'exec'))" install --record C:\Users\xxx\AppData\Local\Temp\pip-record-jhmti8_8\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\xxx\AppData\Local\Temp\pip-install-6vcdnb_4\numpy\ file ='C:\Users\xxx\AppData\Local\Temp\pip-install-6vcdnb_4\numpy\setup.py';f=getattr(tokenize, 'open', open)( file );code=f.read ().replace('\r\n', '\n');f.close();exec(compile(code, file , 'exec'))" install --record C:\Users\xxx\AppData \Local\Temp\pip-record-jhmti8_8\install-record.txt --single-version-externally-managed --compile" 失败,错误代码 1 in C:\Users\xxx\AppData\Local\Temp\pip-安装-6vcdnb_4\numpy\

but I have no idea what´s the problem...但我不知道是什么问题...

Does anybody has a solution for this?有人对此有解决方案吗?

I use Windows and python version 3.7.0b4我使用 Windows 和 python 版本 3.7.0b4

You might be using the python 32-bit version which you need to uninstall and you will need to switch to the python 64-bit version.您可能正在使用需要卸载的 python 32 位版本,并且需要切换到 python 64 位版本。

After switching everything will work fine, just upgrade pip and setuptools before installing.切换后一切正常,安装前只需升级pip和setuptools。

Ok, here is a working solution (at least on windows 10 & python3.7):好的,这是一个有效的解决方案(至少在 Windows 10 和 python3.7 上):

Go here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#spacy去这里: https : //www.lfd.uci.edu/~gohlke/pythonlibs/#spacy

Search SpaCy and download the correct wheels for your platform :-搜索SpaCy并为您的平台下载正确的轮子:-

  • preshed预制
  • cymem cymem
  • murmurhash杂音杂音
  • thinc薄的
  • spacy空间

Then you need to install them with pip install [wheel] in the above order.然后你需要按照上面的顺序用pip install [wheel]安装它们。

If this doesn't work, try installing scipy and maybe even numpy from the same site.如果这不起作用,请尝试从同一站点安装scipy甚至numpy

It took me a while to get spaCy installed correctly, I am on Windows and running python 3.6.4.我花了一段时间才能正确安装 spaCy,我在 Windows 上运行 python 3.6.4。 I'll share my installation process in case it helps anyone.我会分享我的安装过程,以防它对任何人有帮助。

I am using pycharm as my IDE and working from the venv it creates.我使用 pycharm 作为我的 IDE,并使用它创建的venv工作。

I also had similar problems to the OP and managed to get it working outside the venv .我也遇到了与 OP 类似的问题,并设法让它在venv之外工作。

The main issue appeared to be with pip .主要问题似乎与pip 有关

First of all, I deleted my pip cache as it appeared to be causing troubles (atleast on my machine).首先,我删除了我的pip缓存,因为它似乎引起了麻烦(至少在我的机器上)。 On windows it is located on:在 Windows 上,它位于:

C:\Users\YOUR_USERNAME\AppData\Local\pip\cache

Just delete the folder.删除文件夹就行了。

Then I had to upadte pip to the latest version for the installation to work,然后我不得不更新 pip 到最新版本才能安装工作,

python -m pip install --upgrade pip

Check your pip version (at the time of this comment the latest version is 10.0.1)检查您的 pip 版本(在此评论时,最新版本为 10.0.1)

python -m pip --version

After this process I managed to get it working by installing it with pip在这个过程之后,我设法通过用 pip 安装它来让它工作

python -m pip install spacy

The following two commans should be enough:以下两个命令应该足够了:

pip install -U spacy

python -m spacy download en

Note that on Windows you should execute the commands with 'Run as Administrator' privileges.请注意,在 Windows 上,您应该以“以管理员身份运行”权限执行命令。

I was using windows10 64bits and python 3.8.2( 32bits ) and don't work for me.我使用的是 windows10 64bits 和 python 3.8.2( 32bits ),对我不起作用。 I Uninstalled python 32 bits and installed python 64bits, so it work now!我卸载了python 32位并安装了python 64位,所以它现在可以工作了!

Upgrading the pip and the setuptools generally helps.升级 pip 和 setuptools 通常会有所帮助。
Here are 3 steps:这里有3个步骤:

pip install pip -U
pip install setuptools -U
pip install -U spacy

Key is -U which upgrades all packages to the newest available version.关键是-U将所有软件包升级到最新的可用版本。

Uninstall Python32 bit and install Python 64 bit..卸载 Python32 位并安装 Python 64 位..

Worked for me!为我工作!

Was able to solve issue by installing Python 3.7 of 64 bit.能够通过安装 64 位的 Python 3.7 来解决问题。 You can refer https://github.com/explosion/spaCy/issues/4581你可以参考https://github.com/explosion/spaCy/issues/4581

I experienced absolutely the same problem today.我今天遇到了完全相同的问题。

It turned out that the Python I had installed was 32 bit.原来我安装的 Python 是 32 位的。 Uninstalled it and added 64 bit version.卸载它并添加64位版本。 My Windows 10 is 64 bit too.我的 Windows 10 也是 64 位的。 Tried again installing spaCy and it worked.再次尝试安装 spaCy 并且成功了。

Cause原因

It usually happened when your installation accidently stop , some of the data remain in cache which causes the problem .这通常发生在您的安装意外停止时,一些数据保留在缓存中从而导致问题。

Note : this type of error can also be occured in other packages.注意:这种类型的错误也可能发生在其他包中。

Solution解决方案

  • Go to that directory去那个目录

    C:\\Users\\User_Name\\AppData\\Local\\pip\\cache C:\\Users\\User_Name\\AppData\\Local\\pip\\cache

  • Delete cache file删除缓存文件

  • Then upgrading the pip然后升级pip

    python -m pip install --upgrade pip python -m pip install --upgrade pip

  • Install the package you want安装你想要的包

    python -m pip install spacy python -m pip 安装 spacy

If you are using Python 3.8, I strongly advise you to downgrade the python version to 3.7.如果您使用的是 Python 3.8,我强烈建议您将 Python 版本降级到 3.7。 I was trying to solve the issue for 5 hours, finally, after changing the eve to 3.7 it worked.我试图解决这个问题 5 个小时,最后,在将 eve 更改为 3.7 后,它起作用了。

conda create --name chatterbot_example python=3.7

source activate chatterbot_example

pip install chatterbot
pip install chatterbot-corpus

I recently had the same issue and unfortunately, these explanations helped progress but did not solve the problem.我最近遇到了同样的问题,不幸的是,这些解释有助于进步,但没有解决问题。 I have windows 64-bit laptop.我有 Windows 64 位笔记本电脑。 Python version is 3.8.5 and 64 bit. Python 版本是 3.8.5 和 64 位。

I followed the below steps to install stacy我按照以下步骤安装 stacy

  1. Uninstall all python installs on my system (32 bit installs will cause issues)卸载我系统上的所有 python 安装(32 位安装会导致问题)
  2. Go to this link to make sure which version of python has all the below packages.转到此链接以确保哪个版本的 python 具有以下所有包。 All these packages are a pre-req for spacy所有这些软件包都是 spacy 的先决条件

Go here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#spacy去这里: https : //www.lfd.uci.edu/~gohlke/pythonlibs/#spacy

preshed, cymem, murmurhash, thinc, spacy preshed、cymem、murmurhash、thinc、spacy

example: preshed‑3.0.2‑cp38‑cp38‑win_amd64.whl > cp38 meaning 3.8 version.例如:preshed‑3.0.2‑cp38‑cp38‑win_amd64.whl > cp38 表示 3.8 版本。 You can go up to the latest version on all these packages and install the same python version.您可以升级到所有这些软件包的最新版本并安装相同的 Python 版本。

  1. Install Python 3.8.5 version安装 Python 3.8.5 版本

  2. run pip3 install spacy运行 pip3 install spacy

At the time of this writing python 3.8 is the max that you can install spacy on.在撰写本文时,python 3.8 是您可以安装 spacy 的最大值。

For me the issue was I was trying to install spacy on python 3.9 version and downgrading to 3.8.6 fixed the issue.对我来说,问题是我试图在 python 3.9 版本上安装 spacy 并降级到 3.8.6 解决了这个问题。

Note: I spent almost 4 hours to fix this and this is the only page that has almost all the options that you will need to fix the issues.注意:我花了将近 4 个小时来解决这个问题,这是唯一一个几乎包含解决问题所需的所有选项的页面。

在我从 Python 3.9.0 切换到 3.8.6 后它起作用了

I also had the same issue on Ubuntu, finally followed this guide .我在 Ubuntu 上也遇到了同样的问题,最终遵循了本指南

On Ubuntu(python v3.7.9),在 Ubuntu(python v3.7.9)上,

pip install -U pip setuptools wheel
pip install -U spacy
python -m spacy download en_core_web_sm

Hope this helps you save time.希望这可以帮助您节省时间。

i just deleted the cache and it works fine to me.我刚刚删除了缓存,它对我来说很好用。

  1. go to C:\\Users\\XYZ\\AppData\\Local\\pip and then delete the cache folder转到 C:\\Users\\XYZ\\AppData\\Local\\pip 然后删除缓存文件夹
  2. Then upgrade your pip然后升级你的 pip

python -m pip install --upgrade pip 3.now install spacy pip install spacy python -m pip install --upgrade pip 3.now install spacy pip install spacy

pip install nltk

# all package installation attempt would install dependencies first
# resulting not compatible thinc, wasabi, srsly to be installed before completly 
# uninstalling spacy dependency pacakage if any 

pip uninstall srsly
pip uninstall thinc
pip uninstall wasabi    

# install wheel
pip install -U pip setuptools wheel

# upgrade python pip
python -m pip install --upgrade pip

# installing spacy for resume parser needs to be above 2.1.4 closer to this version better 
# to install exactly 2.1.4 version of spacy use
pip install spacy==2.1.4

# below code installs any spacy version above 2.1.4
pip3 install spacy>=2.1.4

# once spacy is installed check if wasabi, thinc and srsly is installed
# installing en-core-web-sm from spacy
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.1/en_core_web_sm-2.3.1.tar.gz

# check for spacy version installed using either of the following
pip show spacy
python -m spacy info
python -m spacy validate

# to get all installed pacakages 
pip freeze

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

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