python - 如何安装 spacy 并避免 32/64 位错误?
问题描述
我试图执行
pip install spacy
它最终与 Python 3.7 64 位(不是 32 位版本)一起工作,但安装后没有其他包导入,如 pandas 正在工作。似乎安装是根本原因,但删除 spacy 后,pandas 和许多其他包的导入错误仍然相同。
重新安装 python 后(我总是直接将它安装在文件夹 C:\Python 中),我可以成功安装 pandas 和所有其他包而不会出现以下错误,但我仍然无法使用 Spacy,因为我会收到导入错误:
OSError: [WinError 193] %1 不是有效的 Win32 应用程序
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-1-7dd3504c366f> in <module>
----> 1 import pandas as pd
c:\python\lib\site-packages\pandas\__init__.py in <module>
9 for dependency in hard_dependencies:
10 try:
---> 11 __import__(dependency)
12 except ImportError as e:
13 missing_dependencies.append("{0}: {1}".format(dependency, str(e)))
~\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py in <module>
138
139 # Allow distributors to run custom init code
--> 140 from . import _distributor_init
141
142 from . import core
~\AppData\Roaming\Python\Python37\site-packages\numpy\_distributor_init.py in <module>
24 # NOTE: would it change behavior to load ALL
25 # DLLs at this path vs. the name restriction?
---> 26 WinDLL(os.path.abspath(filename))
27 DLL_filenames.append(filename)
28 if len(DLL_filenames) > 1:
c:\python\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
362
363 if handle is None:
--> 364 self._handle = _dlopen(self._name, mode)
365 else:
366 self._handle = handle
OSError: [WinError 193] %1 ist keine zulässige Win32-Anwendung´´´
解决方案
您目前有两个不同的site-package
文件夹从中导入包:
c:\python\lib\site-packages
和
~\AppData\Roaming\Python\Python37\site-packages
在我看来,您的系统上当前混合了不同的 python 安装,或者是以前安装的残留版本,然后是不完全删除的版本。因此,我建议:
- 删除所有 python 安装
- 完全删除两者
c:\python
和~\AppData\Roaming\Python
- 仅重新安装一个 python 发行版。如果您不在乎使用哪个版本,请选择 64 位版本
推荐阅读
- r - 如何通过从另一个变量中提取字符串来构建新变量
- android-source - 适用于汽车的 Android 应用程序:停车/充电/导航
- javascript - 将 Hook 传递给孙子/多个组件
- loops - 如何在 Fortran 中将随机数放入循环中
- python-3.x - sqlite3.OperationalError:没有这样的表:
- javascript - Nodejs拆分大数组并进行多个API调用
- three.js - threejs GLTF 模型被拉伸了?
- r - 如何将具有 0 级别的因子的值作为原始数字返回
- debugging - 应用重启后 WEB 丢失数据的 shared_preferences
- json - 删除 JSON 文件中重复的 1:M 表示