简体   繁体   English

在主要的Python安装中导入模块时出错:从不存在的venv Python调用模块

[英]Error when importing module in main Python installation: module is called from an inexistent venv Python

I am working in an IPython interpreter started from the terminal (MacOSX) with just an ipython + enter . 我正在从终端(MacOSX)启动的IPython解释器中,仅使用ipython + enter When I try to import pandas , I get the following error: 当我尝试导入pandas ,出现以下错误:

/Users/myusername/Documents/somefolder/virtualenvironment/adam_py/lib/python2.7/site-packages/pandas/__init__.py in <module>()
  4 
  5 try:
  ----> 6     from . import hashtable, tslib, lib
  7 except Exception:  # pragma: no cover
  8     import sys

/Users/myusername/tslib.pyx in init pandas.tslib (pandas/tslib.c:64182)()

ImportError: No module named compat

The first line of that error suggests that python is looking for pandas in a venv in a folder I deleted some time ago. 该错误的第一行表明python在我前一段时间删除的文件夹中的venv中寻找熊猫。 I get a similar error when I try to import geopandas. 尝试导入Geopandas时,出现类似的错误。

My Python installation is a homebrewed one. 我的Python安装是自制的。 When I run which python in the terminal, I get this: 当我在终端中运行which python时,我得到了:

/usr/local/bin/python

I have been installing libraries with pip install a_library 我一直在使用pip install a_library安装库

What should I do? 我该怎么办?

I just deleted the folder containing the former virtual environment, closed the interpreter, pip-uninstalled pandas, pip-installed it again, and reopened the interpreter. 我只是删除了包含以前虚拟环境的文件夹,关闭了解释器,pip卸载了pandas,再次pip安装了它,然后重新打开了解释器。 Now I can import pandas without problems. 现在我可以毫无问题地进口大熊猫了。

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

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