ModuleNotFoundError:No module named '__builtin__' in conda - python

I have looked at other answers such as conda install future and others but none seem to solve this error. Everything was working till yesterday but today when I am trying to run my script I get this error.
I initially thought that I had multiple pandas packages from pip and conda so I uninstalled from both and then installed via conda again. But the error still persists.
I have installed python 3.6 as a separate environment in anaconda 2.
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'
=============
EDIT 1
Following #EvgenyPogrebnyak's advice I created a new env named py36. I tried running the print statement python -c "import pandas as pd; print(pd.__version__)" statement from the home directory or infact any other directory it runs fine but when I run it from my project directory I get this particular error, which is weird.
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'

I think code below should run. Exit enviornments is you are in one before running.
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
Does this run? You can install more libraries requred with conda install -n new1 <package> then try:
python /Users/amit/Work/ml/marl/nameserver.py
Similar result can be achieved with pipenv.

Related

Unable to run pip3 - ModuleNotFoundError

I am using Ubuntu 18.04 and Python3.7.1. I am trying to run pip3, but I get an error with the lsb_release program:
$ pip3 -V
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ModuleNotFoundError: No module named 'pip._vendor.distro'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
...
File "/usr/share/python-wheels/distro-1.0.1-py2.py3-none-any.whl/distro.py", line 932, in _get_lsb_release_info
subprocess.CalledProcessError: Command 'lsb_release -a' returned non-zero exit status 1.
I don't see what's wrong, the file starts with the right header:
#!/usr/bin/python3 -Es
I can see pip3 is actually there:
$ whereis pip3
pip3: /usr/bin/pip3 /usr/share/man/man1/pip3.1.gz
I tried uninstalling and reinstalling pip3, but nothing changed.
EDIT:
This solved my problem:
https://askubuntu.com/a/1003535/619372

exchangelib: looking for winkerberos on an OS X system

I am attempting to install exchangelib on a Mac (OS X 10.13.5). I was having issues with the install, so I created a minimal environment in which to work:
pushd /tmp
curl -SLO https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash ./Miniconda3-latest-MacOSX-x86_64.sh -b -p /tmp/lxml
source /tmp/lxml/bin/activate
conda create -n py35 python=3.5 lxml -y
source activate py35
I then installed exchangelib within that environment. When I attempt to use it, though, I find that it's trying to load winkerberos instead of pykerberos.
>>> import exchangelib
Traceback (most recent call last):
File "/tmp/lxml/envs/py35/lib/python3.5/site-packages/requests_kerberos/kerberos_.py", line 2, in <module>
import kerberos
ImportError: dlopen(/tmp/lxml/envs/py35/lib/python3.5/site-packages/kerberos.cpython-35m-darwin.so, 2): Symbol not found: _mempcpy
Referenced from: /tmp/lxml/envs/py35/lib/python3.5/site-packages/kerberos.cpython-35m-darwin.so
Expected in: flat namespace
in /tmp/lxml/envs/py35/lib/python3.5/site-packages/kerberos.cpython-35m-darwin.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/tmp/lxml/envs/py35/lib/python3.5/site-packages/exchangelib/__init__.py", line 4, in <module>
from .account import Account
File "/tmp/lxml/envs/py35/lib/python3.5/site-packages/exchangelib/account.py", line 12, in <module>
from exchangelib.services import GetUserOofSettings, SetUserOofSettings
File "/tmp/lxml/envs/py35/lib/python3.5/site-packages/exchangelib/services.py", line 37, in <module>
from .transport import wrap, extra_headers, SOAPNS, TNS, MNS, ENS
File "/tmp/lxml/envs/py35/lib/python3.5/site-packages/exchangelib/transport.py", line 9, in <module>
import requests_kerberos
File "/tmp/lxml/envs/py35/lib/python3.5/site-packages/requests_kerberos/__init__.py", line 17, in <module>
from .kerberos_ import HTTPKerberosAuth, REQUIRED, OPTIONAL, DISABLED
File "/tmp/lxml/envs/py35/lib/python3.5/site-packages/requests_kerberos/kerberos_.py", line 4, in <module>
import winkerberos as kerberos
ImportError: No module named 'winkerberos'
>>>
I'm kind of at a loss here. Any ideas how to get the install to not look for winkerberos?
It looks like it is trying to load pykerberos first, which fails with a library issue (Symbol not found: _mempcpy) and as a fallback tries to load winkerberos, which it does not find. This should start working as soon as you can make the pykerberos on your system work.

Can't find submodule in package

I'm using Anaconda3 version 4.2.0 on ubuntu (in docker).
Anaconda is installed in /root/anaconda3 folder.
I installed theano_bpr package using pip install theano_bpr.
Now when i open python and try import theano_bpr, i get the following message:
>>> import theano_bpr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/anaconda3/lib/python3.5/site-packages/theano_bpr/__init__.py", line 17, in <module>
from bpr import BPR
ImportError: No module named 'bpr'
However, when i navigate to /root/anaconda3/lib/python3.5/site-packages/theano_bpr/ and run python there, i'm able to import theano_bpr.
In /root/anaconda3/lib/python3.5/site-packages/theano_bpr/ there are following files:
__init__.py, bpr.py (this one is causing problems), t.py, and utils.py.

How to change python module path

I install a python2.7.6 locally, and there is another 2.7.6 installed on cluster publicly.
Then I use my local python to install a pip but when I 'pip list', it returns:
$ pip list Traceback (most recent call last): File
"/home/zengh/.local/bin/pip", line 7, in
from pip import main File "/home/zengh/.local/lib/python2.7/site-packages/pip/init.py", line
13, in
from pip.utils import get_installed_distributions, get_prog File "/home/zengh/.local/lib/python2.7/site-packages/pip/utils/init.py",
line 5, in
import locale File "/home/software/rhel6/python/2.7.6/lib/python2.7/locale.py", line 18,
in
import operator ImportError: /home/software/rhel6/python/2.7.6/lib/python2.7/lib-dynload/operator.so:
undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString
Obviously it calls the locale.py on the cluster while my PYTHONPATH only contains my local python's path. How can I make it call the
/.local/python2.7.6/lib/python2.7/locale.py?
Thanks
Depends on whether you want to set it from within a script or from os.
From script:
import sys
sys.path.append('additional dir')
From os:
export PYTHONPATH=somewhere

ImportError: cannot import name ResourceError

I'm trying to install couchdb app on debian using the following command
couchapp push http://user:pass#localhost:5984/acra-appname
and I'm having the following error output:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/restkit/__init__.py", line 9, in <module>
from restkit.conn import Connection
File "/usr/local/lib/python2.6/dist-packages/restkit/conn.py", line 14, in <module>
from socketpool import Connector
ImportError: No module named socketpool
Traceback (most recent call last):
File "/usr/local/bin/couchapp", line 7, in <module>
from couchapp.dispatch import run
File "/usr/local/lib/python2.6/dist-packages/couchapp/dispatch.py", line 10, in <module>
import couchapp.commands as commands
File "/usr/local/lib/python2.6/dist-packages/couchapp/commands.py", line 15, in <module>
from couchapp import clone_app
File "/usr/local/lib/python2.6/dist-packages/couchapp/clone_app.py", line 15, in <module>
from couchapp.errors import AppError
File "/usr/local/lib/python2.6/dist-packages/couchapp/errors.py", line 7, in <module>
from restkit import ResourceError
ImportError: cannot import name ResourceError
As far as I understand the error is:
ImportError: No module named socketpool
How can I install this module or how to resolve the problem?
As Ifthikhan sugessted: Install it using a package manager such as apt-get and thereafter using pip you can install socketpool.
I had this problem when installing couchapp. I used pip to install it, and I thought it completed, but when I ran it I had the ImportError problem. Turns out the pip install didn't succeed and I first needed to:
apt-get install python-dev
Then when I did a
pip install couchapp
all of the dependencies were installed and couchapp ran without a problem.

Categories

Resources