Ubuntu 无法导入随apt get一起安装的python包

Ubuntu 无法导入随apt get一起安装的python包,ubuntu,pip,apt-get,Ubuntu,Pip,Apt Get,在ubuntu(特别是python:3.7.3-stretch base dockerimage)上,我运行: 这很好。 然后,我尝试通过apt-get安装包(不能用pip安装)。我尝试: $apt获取更新 $apt获取安装python3 grib $python-c“导入pygrib” 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 ModuleNotFoundError:没有名为“pygrib”的模块 (为了简洁起见,省略安装的输出) 为什么我不能导入pygrib?我不在虚拟环境中

在ubuntu(特别是python:3.7.3-stretch base dockerimage)上,我运行:

这很好。 然后,我尝试通过apt-get安装包(不能用pip安装)。我尝试:

$apt获取更新
$apt获取安装python3 grib
$python-c“导入pygrib”
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ModuleNotFoundError:没有名为“pygrib”的模块
(为了简洁起见,省略安装的输出)

为什么我不能导入pygrib?我不在虚拟环境中

我要尝试的第一件事是仔细检查您正在调用的python是否与您安装的
pygrib
相同

  • $which python
  • $python-c“帮助(“模块”)”
  • $python-c“帮助(“模块pygrip”)”
(检查您正在调用的python以及安装了哪些包)

如果这不起作用,那么ubuntu包就有问题了——所以我会尝试从源代码处安装


谢谢我发现我调用了错误的python:哪个python给了我“/usr/local/bin/python”,而pygrib的东西安装在“/usr/lib/python3”中。。如何协调这一点?您可以直接调用python
$/usr/lib/python3 yourscipt.py
,或者只调用
$python3 yourscript.py
$ pip install pandas
$ python -c 'import pandas'
$
$ apt-get update
$ apt-get install python3-grib
$ python -c 'import pygrib'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'pygrib'
Clone the github repository, or download a source release from https://pypi.python.org/pypi/pygrib.

Copy setup.cfg.template to setup.cfg, open in text editor, follow instructions in comments for editing. If you are using the old grib_api library instead of the new eccodes library, be sure to uncomment the last line setup.cfg.

Run 'python setup.py build'

Run 'python setup.py install' (with sudo if necessary)

Run 'python test.py' to test your pygrib installation.