Python import modulr _io error

2k views Asked by At

I have 3 python versions. python2.7 python3 python3.4

I don't have any experience in Python. I haven't used it before. This error exists as part of cluster setup via cloudera manager.

ERROR

 ..........
 >> import mimetools 
  >> File "/usr/lib/python2.7/mimetools.py", line 6, in <module> 
 >> import tempfile 
 >> File "/usr/lib/python2.7/tempfile.py", line 32, in <module> 
 >> import io as _io 
 >> File "/usr/lib/python2.7/io.py", line 51, in <module> 
 >> import _io 
 >>ImportError: No module named _io 
 >>Traceback (most recent call last): 
 >> File "/usr/lib/cmf/agent/src/cmf/agent.py", line 8, in <module> 
 >> import avro.ipc 
 >> File "/usr/lib/cmf/agent/build/env/lib/python2.7/site-packages/avro-1.6.3-py2.7.egg/avro/ipc.py", line 19, in <module> 
 >> import httplib 
 >> File "/usr/lib/python2.7/httplib.py", line 79, in <module> 
 >> import mimetools 
 >> File "/usr/lib/python2.7/mimetools.py", line 6, in <module> 
 >> import tempfile 
 >> File "/usr/lib/python2.7/tempfile.py", line 32, in <module> 
 >> import io as _io 
 >> File "/usr/lib/python2.7/io.py", line 51, in <module> 
 >> import _io 
 >>ImportError: No module named _io 

Tried

Read this

I really don't know where to run accepted answers' commands. And Second answer, which has 30 votes, I tried. It says "cp: ‘/usr/bin/python2.7’ and ‘/usr/bin/python’ are the same file". Anyone please help me?

It's a new ubuntu OS. Not even upgradation.

1

There are 1 answers

1
jcoppens On

If you open a terminal window, you can call python two ways:

python

in which case it will call python 2.7. Or:

python3

in which case, I suspect it will call python 3.4. You normally cannot have two different python3 version operational at the same time. (And I'd suggest removing one of them).

On the other hand, if you install a module, it will install in just one of the Pythons (may depend on which tool you use). So, if you install _io in python 2, it will not be accessible to python3. Some modules may not even be available for both Python flavors.

You can easily try this out. Try importing the module in each of the Pythons:

$ python
>>> import io
??? 
>>> Ctl^D

$ python3
>>> import io

Now, io is a system module, so it should be available. If it isn't, then probably there is confusion in Python3 about where it has to find the module (probably caused by your two versions of Python3).

Now, I'm not familiar with Cloudera. If Cloudera runs Python in a virtual environment, then the confusion might be even greater (and there was probably an installation problem).