Python 包全局安装,但在虚拟环境中失败
Posted
技术标签:
【中文标题】Python 包全局安装,但在虚拟环境中失败【英文标题】:Python package installs globally but fails within virtual environment 【发布时间】:2022-01-22 09:34:47 【问题描述】:我是 Python 新手,很难理解安装包的不同方法。我在 MacOS Catalina 上。
我尝试在终端中安装 Python 包 CytoPy (https://github.com/burtonrj/CytoPy):
pip install cytopy
这安装得很好。我创建了一个文件 test.py:
from cytopy.data.setup import global_init
print("test")
运行良好,即正确导入了 cytopy 包。
然后我在此处遵循此 Visual Studio 中的 Python 入门教程:https://code.visualstudio.com/docs/python/python-tutorial
它说避免将包安装到全局解释器环境中并使用项目特定的虚拟环境很重要。我根据 Visual Studio Code 中终端中的教程创建了一个虚拟环境:
python3 -m venv .venv
source .venv/bin/activate
现在我尝试在虚拟环境中安装包:
pip install cytopy
我最终会遇到大量错误:
主要错误是:
ERROR: Failed building wheel for fdasrsf
Successfully built hdbscan
Failed to build fdasrsf
ERROR: Could not build wheels for fdasrsf, which is required to install
pyproject.toml-based projects
我怎么可能在 Visual Studio Code 中通过终端全局安装,但不能在虚拟环境中安装?
编辑 我按照建议使用了 pip3 。我仍然得到同样的错误。这里还有更多。以下是更多错误日志:
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:83:53: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int pthread_sigmask(int, const sigset_t *, sigset_t *) __DARWIN_ALIAS(pthread_sigmask);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:83:53: note: insert '_Nullable' if the pointer may be null
int pthread_sigmask(int, const sigset_t *, sigset_t *) __DARWIN_ALIAS(pthread_sigmask);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:83:53: note: insert '_Nonnull' if the pointer should never be null
int pthread_sigmask(int, const sigset_t *, sigset_t *) __DARWIN_ALIAS(pthread_sigmask);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:84:43: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigaction(int, const struct sigaction * __restrict,
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:84:43: note: insert '_Nullable' if the pointer may be null
int sigaction(int, const struct sigaction * __restrict,
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:84:43: note: insert '_Nonnull' if the pointer should never be null
int sigaction(int, const struct sigaction * __restrict,
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:85:23: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
struct sigaction * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:85:23: note: insert '_Nullable' if the pointer may be null
struct sigaction * __restrict);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:85:23: note: insert '_Nonnull' if the pointer should never be null
struct sigaction * __restrict);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:86:24: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigaddset(sigset_t *, int);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:86:24: note: insert '_Nullable' if the pointer may be null
int sigaddset(sigset_t *, int);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:86:24: note: insert '_Nonnull' if the pointer should never be null
int sigaddset(sigset_t *, int);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:87:31: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __DARWIN_ALIAS(sigaltstack) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:87:31: note: insert '_Nullable' if the pointer may be null
int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __DARWIN_ALIAS(sigaltstack) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:87:31: note: insert '_Nonnull' if the pointer should never be null
int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __DARWIN_ALIAS(sigaltstack) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:87:53: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __DARWIN_ALIAS(sigaltstack) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:87:53: note: insert '_Nullable' if the pointer may be null
int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __DARWIN_ALIAS(sigaltstack) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:87:53: note: insert '_Nonnull' if the pointer should never be null
int sigaltstack(const stack_t * __restrict, stack_t * __restrict) __DARWIN_ALIAS(sigaltstack) __WATCHOS_PROHIBITED __TVOS_PROHIBITED;
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:88:24: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigdelset(sigset_t *, int);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:88:24: note: insert '_Nullable' if the pointer may be null
int sigdelset(sigset_t *, int);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:88:24: note: insert '_Nonnull' if the pointer should never be null
int sigdelset(sigset_t *, int);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:89:26: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigemptyset(sigset_t *);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:89:26: note: insert '_Nullable' if the pointer may be null
int sigemptyset(sigset_t *);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:89:26: note: insert '_Nonnull' if the pointer should never be null
int sigemptyset(sigset_t *);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:90:25: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigfillset(sigset_t *);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:90:25: note: insert '_Nullable' if the pointer may be null
int sigfillset(sigset_t *);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:90:25: note: insert '_Nonnull' if the pointer should never be null
int sigfillset(sigset_t *);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:94:32: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigismember(const sigset_t *, int);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:94:32: note: insert '_Nullable' if the pointer may be null
int sigismember(const sigset_t *, int);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:94:32: note: insert '_Nonnull' if the pointer should never be null
int sigismember(const sigset_t *, int);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:96:25: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigpending(sigset_t *);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:96:25: note: insert '_Nullable' if the pointer may be null
int sigpending(sigset_t *);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:96:25: note: insert '_Nonnull' if the pointer should never be null
int sigpending(sigset_t *);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:97:37: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:97:37: note: insert '_Nullable' if the pointer may be null
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:97:37: note: insert '_Nonnull' if the pointer should never be null
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:97:60: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:97:60: note: insert '_Nullable' if the pointer may be null
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:97:60: note: insert '_Nonnull' if the pointer should never be null
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:100:31: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigsuspend(const sigset_t *) __DARWIN_ALIAS_C(sigsuspend);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:100:31: note: insert '_Nullable' if the pointer may be null
int sigsuspend(const sigset_t *) __DARWIN_ALIAS_C(sigsuspend);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:100:31: note: insert '_Nonnull' if the pointer should never be null
int sigsuspend(const sigset_t *) __DARWIN_ALIAS_C(sigsuspend);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:28: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:28: note: insert '_Nullable' if the pointer may be null
int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:28: note: insert '_Nonnull' if the pointer should never be null
int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:46: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:46: note: insert '_Nullable' if the pointer may be null
int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:101:46: note: insert '_Nonnull' if the pointer should never be null
int sigwait(const sigset_t * __restrict, int * __restrict) __DARWIN_ALIAS_C(sigwait);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:103:39: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
void psignal(unsigned int, const char *);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:103:39: note: insert '_Nullable' if the pointer may be null
void psignal(unsigned int, const char *);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:103:39: note: insert '_Nonnull' if the pointer should never be null
void psignal(unsigned int, const char *);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:106:31: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigvec(int, struct sigvec *, struct sigvec *);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:106:31: note: insert '_Nullable' if the pointer may be null
int sigvec(int, struct sigvec *, struct sigvec *);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:106:31: note: insert '_Nonnull' if the pointer should never be null
int sigvec(int, struct sigvec *, struct sigvec *);
^
_Nonnull
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:106:48: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int sigvec(int, struct sigvec *, struct sigvec *);
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:106:48: note: insert '_Nullable' if the pointer may be null
int sigvec(int, struct sigvec *, struct sigvec *);
^
_Nullable
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/signal.h:106:48: note: insert '_Nonnull' if the pointer should never be null
int sigvec(int, struct sigvec *, struct sigvec *);
^
_Nonnull
220 warnings generated.
clang -bundle -undefined dynamic_lookup -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/markkelly/.pyenv/versions/3.8.0/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/readline/lib -L/Users/markkelly/.pyenv/versions/3.8.0/lib build/temp.macosx-10.15-x86_64-3.8/src/DP.o build/temp.macosx-10.15-x86_64-3.8/src/optimum_reparam_N.o -o build/lib.macosx-10.15-x86_64-3.8/optimum_reparam_N.cpython-38-darwin.so
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/private/var/folders/pg/g0n4w9955m7ff1rsj6b6tpz40000gn/T/pip-build-env-vgswf17a/overlay/lib/python3.8/site-packages/numpy/core/include -I/Users/markkelly/RedMatter/repos/new_version/cytopy/.venv/include -I/Users/markkelly/.pyenv/versions/3.8.0/include/python3.8 -c src/bayesian.cpp -o build/temp.macosx-10.15-x86_64-3.8/src/bayesian.o
In file included from src/bayesian.cpp:1:
In file included from src/armadillo:26:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:317:9: error: no member named 'signbit' in the global namespace
using ::signbit;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:318:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:319:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
~~^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/math.h:752:12: note: 'finite' declared here
extern int finite(double)
^
In file included from src/bayesian.cpp:1:
In file included from src/armadillo:26:
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:320:9: error: no member named 'isinf' in the global namespace
using ::isinf;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:321:9: error: no member named 'isnan' in the global namespace
using ::isnan;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:322:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:323:9: error: no member named 'isgreater' in the global namespace
using ::isgreater;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:324:9: error: no member named 'isgreaterequal' in the global namespace
using ::isgreaterequal;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:325:9: error: no member named 'isless' in the global namespace
using ::isless;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:326:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:327:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:328:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:329:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
~~^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:640:26: error: no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:640:60: error: no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:641:18: error: no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:641:50: error: no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:646:17: error: no template named 'numeric_limits'
static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
^
/Library/Developer/CommandLineTools/usr/bin/../include/c++/v1/cmath:649:25: error: no template named 'numeric_limits'
return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
setup.py:47: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
mac_ver = str(LooseVersion(get_config_var('MACOSX_DEPLOYMENT_TARGET')))
not modified: 'build/_DP.c'
好像和CommandLineTools有关
编辑
继续 Alan 下面的评论,当我转到 Visual Studio Code > Command Palette > Python:选择解释器时,我看到了:
【问题讨论】:
也许pip
使用的是 Python 2,而不是 Python 3,因此您可以在全局和虚拟环境中获得不同的 Python 版本。
检查您没有安装多个版本的 python3 - 以及什么版本。这不常见但并非不可能。许多基于 C/C++ 的软件包需要一段时间才能移植到最新版本的 Python 和降级帮助。您的系统 python 可能与 venv 不同,或者您的系统上可能已经有一个不在 venv 中的依赖项/配置。
@Alan 是的,我似乎有很多版本,请检查我的编辑
你能检查一下这个包是否适用于两个版本吗?
在一个 venv 中对我来说很奇怪,它说它找不到 cytopy。
【参考方案1】:
你的环境是python3,mac上的pip是python2。我想。尝试使用 pip3 进行安装或在 python2 中运行您的环境。可能正在使用不同的 python 版本。
【讨论】:
试过了,没成功【参考方案2】:我认为您尝试使用的库在 python3.6 和 python3.7 上受支持。我认为你的默认全局 python 版本是 2.7,但你的 venv 是用 python3.8 创建的,因此出错。
尝试使用 2.7、3.6 或 3.7 python 之一创建 venv,然后重试。
我发现:
python<version optionally> -m pip install <sth>
总是使用正确的点子,省去了我很多挠头和拉头发的麻烦。
【讨论】:
【参考方案3】:所以我首先要注意的是,您要使用的软件包 CytoPy 的文档有一个专门用于安装和配置 CytoPy 的页面。此页面可以访问here。
此页面列出了必须按顺序执行的各个步骤,包括installing MongoDB、installing NumPy 和其他步骤。安装过程非常具体和详细,所以我想强调一些重要的事情。首先,您必须确保使用正确版本的 Python,即3.8。此外,您希望拥有正确版本的 NumPy,即1.19。
此外,CytoPy 强烈建议使用 Conda 而不是 venv 创建环境,这通常是使用包含非 Python 语言代码的工具(包括许多数据和包含编译语言模块的科学计算工具)的好建议例如 C 或 C++)。有关 Conda 与 venv 的更多差异,请参阅this article。
此外,虽然这不是绝对必要的,但如果您计划在未来进行大量科学计算和基于数据的计算,或者您计划在您用于此项目的环境中安装许多不同的包,我强烈建议查看Mamba,这是一个更快、改进的 Conda 版本,但根据您的具体意图,此项目可能不需要这样做。
更一般地说,虽然遵循一般 Python 教程(例如您在 VSCode 中提到的那个)当然没有错,但您通常最好从特定包中查看更具体的安装过程/建议你想使用的以及你所在的计算领域推荐的“最佳实践”。事实上,这在VSCode教程here中实际上已经提到:
数据科学:如果您使用 Python 的主要目的是数据科学,那么您可以考虑从 Anaconda 下载。 Anaconda 不仅提供了 Python 解释器,还提供了许多用于数据科学的有用库和工具。
【讨论】:
以上是关于Python 包全局安装,但在虚拟环境中失败的主要内容,如果未能解决你的问题,请参考以下文章