ModuleNotFoundError:conda中没有名为'__builtin__'的模块
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ModuleNotFoundError:conda中没有名为'__builtin__'的模块相关的知识,希望对你有一定的参考价值。
我看过其他答案,如conda install future
和其他答案,但似乎没有解决这个错误。一切都工作到昨天,但今天当我试图运行我的脚本时,我得到了这个错误。
我最初认为我有来自pip和conda的多个pandas软件包,所以我从两者中卸载然后再通过conda安装。但错误仍然存在。
我已经在anaconda 2中安装了python 3.6作为一个单独的环境。
Traceback (most recent call last):
File "/Users/amit/anaconda2/envs/python36/lib/python3.6/site-packages/pandas/compat/__init__.py", line 49, in <module>
import __builtin__ as builtins
ModuleNotFoundError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 18, in <module>
from nameserver import NameServer
File "/Users/amit/Work/ml/marl/nameserver.py", line 4, in <module>
import pandas as pd
File "/Users/amit/anaconda2/envs/python36/lib/python3.6/site-packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "/Users/amit/anaconda2/envs/python36/lib/python3.6/site-packages/pandas/compat/__init__.py", line 62, in <module>
import http.client as httplib
ModuleNotFoundError: No module named 'http.client'
=============
编辑1
按照@ EvgenyPogrebnyak的建议,我创建了一个名为py36
的新环境。我尝试从主目录运行print语句python -c "import pandas as pd; print(pd.__version__)"
语句或者事实上运行正常的任何其他目录但是当我从我的项目目录运行它时,我得到这个特殊错误,这很奇怪。
amit:~ $source activate py36
(py36) amit:~ $python -c "import pandas as pd; print(pd.__version__)"
0.23.0
(py36) amit:~ $cd Work/ml/marl/
(py36) amit:~/Work/ml/marl $python -c "import pandas as pd; print(pd.__version__)"
Traceback (most recent call last):
File "/Users/amit/anaconda2/envs/py36/lib/python3.6/site-packages/pandas/compat/__init__.py", line 49, in <module>
import __builtin__ as builtins
ModuleNotFoundError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/amit/anaconda2/envs/py36/lib/python3.6/site-packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "/Users/amit/anaconda2/envs/py36/lib/python3.6/site-packages/pandas/compat/__init__.py", line 62, in <module>
import http.client as httplib
ModuleNotFoundError: No module named 'http.client'
我认为下面的代码应该运行。退出环境是你在运行之前的一个环境。
conda create -n new1 python=3.6 pandas
source activate new1
python --version
# expected:
# Python 3.6.0 :: Anaconda 4.3.0 (32-bit)
python -c "import pandas as pd; print(pd.__version__)"
# expected '0.22.0',but more importantly this shows pandas in imported
这会运行吗?您可以使用qazxsw poi安装更多库,然后尝试:
conda install -n new1 <package>
使用python /Users/amit/Work/ml/marl/nameserver.py
可以获得类似的结果。
以上是关于ModuleNotFoundError:conda中没有名为'__builtin__'的模块的主要内容,如果未能解决你的问题,请参考以下文章
ModuleNotFoundError: No module named 'conda,这个怎么办,模块找不到 python3
PyInstaller ModuleNotFoundError --paths 标志似乎不起作用
使用jupyter notebook 时明明已经安装了某个lib,还是出现ModuleNotFoundError
使用jupyter notebook 时明明已经安装了某个lib,还是出现ModuleNotFoundError