简体   繁体   English

为什么我的 Anaconda 安装 Python 找不到一些包?

[英]Why can't my Anaconda install of Python find some packages?

For some reason, I seem unable to import certain modules in my macOS Anaconda install of Python.出于某种原因,我似乎无法在 Python 的 macOS Anaconda 安装中导入某些模块。

$which python
/opt/anaconda3/bin/python

I can use some packages (pandas loads fine, for example), but wget and pypdf2 cannot be found.我可以使用一些包(例如 pandas 可以很好地加载),但是找不到 wget 和 pypdf2。 I've removed and installed both again using the following commands:我已经使用以下命令再次删除并安装了两者:

$conda install -c conda-forge pypdf2
$conda install -c anaconda wget

They appear to be installed:它们似乎已安装:

$conda list
# Name                    Version                   Build  Channel
pypdf2                    1.26.0                   pypi_0    pypi
wget                      1.20.1               h051b688_0    anaconda

When importing, I get the following 'module not found' errors导入时,出现以下“找不到模块”错误

>>>import wget
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'wget'

>>>import pypdf2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pypdf2'
   

Any ideas what's going on here and what else I can do to troubleshoot?知道这里发生了什么以及我还能做些什么来解决问题吗? Thank you.谢谢你。

wget is not a Python package. It is a command-line program used to download things from the inte.net. wget不是 Python package。它是一个用于从 inte.net 下载东西的命令行程序。 You can use it as wget on the command-line.您可以在命令行上将其用作wget

Your error with pypdf2 occurs because you are not importing it properly. pypdf2出现错误是因为您没有正确导入它。 Use采用

import PyPDF2

as per the examples .根据示例

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

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