在 Anaconda 中更新 Statsmodels
Updating Statsmodels in Anaconda
我遇到的根本问题是当我尝试在 Mac OS 中的 Anaconda Jupyter Notebook 中调用 statsmodels.stats.proportion
的 test_proportions_2indep 属性时,我得到以下信息错误:
AttributeError: module 'statsmodels.stats.proportion' has no attribute 'test_proportions_2indep'
我假设这是因为 Statsmodels 没有正确更新。当我调用 statsmodels.__version__
时,它说我在当前环境中安装了 0.11.1
,但文档页面中的版本是 0.12.1
。
我已采取以下步骤:
- 我删除了Anaconda,删除了所有相关文件,然后重新下载。我已经删除并重新安装了 Statsmodels。
- 我尝试在 Jupyter 中使用以下命令更新 Statsmodels:
! conda update statsmodels -y
、! conda update statsmodels=0.12.1 -y
和 ! conda install -c conda-forge statsmodels
。
- 我检查了 Anaconda 应用程序并尝试在那里删除并重新安装 Statsmodels,但是 运行 遇到了要卸载一堆不同包的情况,所以我认为我对环境的理解工作还没有跟上速度。不知道这里有没有解决办法
最后,我给出了以下命令 (! conda install update statsmodels==0.12.1 -y
),并在命令行中得到了一个新的 error/response:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- statsmodels==0.12.1
- update
Current channels:
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
当然,Statsmodels版本还是0.10.1。
因此:1. 我是否需要更新 Statsmodels 才能使用此属性?和 2. 如何更新它?
过去,当我尝试从基础环境升级包时,我遇到过很多关于 Anaconda 的问题。这是我的推荐:
创建您自己的环境。您可以从 Anaconda GUI 或命令行执行此操作,如下所示:
conda create --name newenv
现在您可以通过以下方式激活此环境:
conda activate newenv
如果您想查看所有可用的环境:
conda info --envs
对我来说,这会打印以下内容:
base C:\ProgramData\Anaconda3
myenv C:\Users\james\.conda\envs\myenv
newenv * C:\Users\james\.conda\envs\newenv
你可以从 *
看出我目前在 newenv
。
现在我可以使用 pip
来显示我当前安装的 statsmodels
。
pip show statsmodels
对我来说这表明:
Name: statsmodels
Version: 0.11.0
Summary: Statistical computations and models for Python
Home-page: https://www.statsmodels.org/
Author: None
Author-email: None
License: BSD License
Location: c:\programdata\anaconda3\lib\site-packages
Requires: numpy, scipy, pandas, patsy
Required-by:
要升级到最新最好的版本,我只需使用 conda update
来升级它。
conda update statsmodels
pip show statsmodels
现在显示我已经安装了版本 0.12.1。
我也强烈推荐 conda cheatsheet。它包含您在 conda 中熟悉所需的所有命令行内容。
我遇到的根本问题是当我尝试在 Mac OS 中的 Anaconda Jupyter Notebook 中调用 statsmodels.stats.proportion
的 test_proportions_2indep 属性时,我得到以下信息错误:
AttributeError: module 'statsmodels.stats.proportion' has no attribute 'test_proportions_2indep'
我假设这是因为 Statsmodels 没有正确更新。当我调用 statsmodels.__version__
时,它说我在当前环境中安装了 0.11.1
,但文档页面中的版本是 0.12.1
。
我已采取以下步骤:
- 我删除了Anaconda,删除了所有相关文件,然后重新下载。我已经删除并重新安装了 Statsmodels。
- 我尝试在 Jupyter 中使用以下命令更新 Statsmodels:
! conda update statsmodels -y
、! conda update statsmodels=0.12.1 -y
和! conda install -c conda-forge statsmodels
。 - 我检查了 Anaconda 应用程序并尝试在那里删除并重新安装 Statsmodels,但是 运行 遇到了要卸载一堆不同包的情况,所以我认为我对环境的理解工作还没有跟上速度。不知道这里有没有解决办法
最后,我给出了以下命令 (! conda install update statsmodels==0.12.1 -y
),并在命令行中得到了一个新的 error/response:
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- statsmodels==0.12.1
- update
Current channels:
- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
当然,Statsmodels版本还是0.10.1。
因此:1. 我是否需要更新 Statsmodels 才能使用此属性?和 2. 如何更新它?
过去,当我尝试从基础环境升级包时,我遇到过很多关于 Anaconda 的问题。这是我的推荐:
创建您自己的环境。您可以从 Anaconda GUI 或命令行执行此操作,如下所示:
conda create --name newenv
现在您可以通过以下方式激活此环境:
conda activate newenv
如果您想查看所有可用的环境:
conda info --envs
对我来说,这会打印以下内容:
base C:\ProgramData\Anaconda3
myenv C:\Users\james\.conda\envs\myenv
newenv * C:\Users\james\.conda\envs\newenv
你可以从 *
看出我目前在 newenv
。
现在我可以使用 pip
来显示我当前安装的 statsmodels
。
pip show statsmodels
对我来说这表明:
Name: statsmodels
Version: 0.11.0
Summary: Statistical computations and models for Python
Home-page: https://www.statsmodels.org/
Author: None
Author-email: None
License: BSD License
Location: c:\programdata\anaconda3\lib\site-packages
Requires: numpy, scipy, pandas, patsy
Required-by:
要升级到最新最好的版本,我只需使用 conda update
来升级它。
conda update statsmodels
pip show statsmodels
现在显示我已经安装了版本 0.12.1。
我也强烈推荐 conda cheatsheet。它包含您在 conda 中熟悉所需的所有命令行内容。