ImportError: No module named _io - python

When I compile my python scripts I'm getting the following error message. This started happening when I installed Anaconda. I've tried to find a solution online to the problem but I've had no luck. Can anyone help with solving this?
Traceback (most recent call last):
File "query.py", line 1, in <module>
import mysql.connector
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/__init__.py", line 37, in <module>
from .connection import MySQLConnection
File "/usr/local/lib/python2.7/dist-packages/mysql/connector/connection.py", line 27, in <module>
from io import IOBase
File "/usr/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: No module named _io

Are you using virtualenv? When I ran into this issue it was because of some server update which messed with the python version being used by my virtualenv. I solved the problem by deleting the virtualenv and making a new identical one.

Related

ModuleNotFoundError: No module named '_sqlite3' Error when try to import sqlite3 and Django in Ubuntu

I tried to Create Django Project. I'm able to create project but not able to run the runserver command. I got below error. I also tried to import sqlite3 got same error
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.11/sqlite3/__init__.py", line 57, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.11/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ModuleNotFoundError: No module named '_sqlite3'
>>>
Python version: Python 3.11.0
As Chris suspected the Python 3.11 is causing the issues I don't know why but I just downgraded to 3.8.10 and it resolved the issue.

Facing error messages when importing sklearn in python i.d

I get an error when importing sklearn in python 3.9.
I am using I.D.L.E. in Windows.
Installed it using cmd command: pip install -U scikit-learn as given in https://scikit-learn.org/stable/install.html
The received error message is:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
import sklearn
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py", line 17, in <module>
from .utils import _IS_32BIT
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\__init__.py", line 29, in <module>
from .fixes import parse_version, threadpool_info
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\fixes.py", line 19, in <module>
import scipy.stats
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\__init__.py", line 453, in <module>
from ._stats_py import *
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\_stats_py.py", line 38, in <module>
from scipy.spatial.distance import cdist
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\spatial\__init__.py", line 104, in <module>
from ._qhull import *
ImportError: DLL load failed while importing _qhull: The specified module could not be found.
Please help.
Since the required file _qhull.yp39-win_amd64.pyd is there, it must be a problem with the dependencies this DLL file has and can't find on your computer.
Use a dependency walker like this one to find out what is missing on your system and see that you get those missing pieces installed.
Quite likely you are missing some of the Microsoft Redistributable Visual Studio Files.
Apparently my scipy got corrupted somehow. Uninstalling and re-installing it fixed the problem. Thanks everyone who took their time and effort to help though.

"ImportError: No module named six" ubuntu 20.04

when running "src/bitmessagemain.py" in the terminal it shows
Traceback (most recent call last):
File "src/bitmessagemain.py", line 33, in <module>
import shared
File "/home/otsudo/Desktop/PyBitmessage-0.6/src/shared.py", line 19, in <module>
import highlevelcrypto
File "/home/otsudo/Desktop/PyBitmessage-0.6/src/highlevelcrypto.py", line 16, in <module>
from bmconfigparser import BMConfigParser
File "/home/otsudo/Desktop/PyBitmessage-0.6/src/bmconfigparser.py", line 10, in <module>
from six import string_types
ImportError: No module named six
I am guessing it has to do something with the virtualenv due to bitmessage still running on python 2.7 but I cant figure it out. I've made the environment for bitmessage to run in and I keep getting the error.
You probably don't have the six Python module installed,
try this:
pip install six

ImportError: cannot import name 'tqdm' from 'conda._vendor.tqdm' (unknown location)

Hello I am using mac actually when I searched analytics in finder I removed some folders (I thought they are useless :) after that when I type conda update or such I am getting those errors and further more.
I am keeping exact error:
Traceback (most recent call last):
File "/Users/nunemunthalashiva/anaconda3/bin/conda", line 13, in <module>
sys.exit(main())
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/cli/main.py", line 151, in main
from ..exceptions import conda_exception_handler
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/exceptions.py", line 25, in <module>
from .common.io import dashlist, timeout
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/common/io.py", line 33, in <module>
from .._vendor.tqdm import tqdm
ImportError: cannot import name 'tqdm' from 'conda._vendor.tqdm' (unknown location)
Python comes with some libraries that are required to preform some basic operation later in python such as update or install libraries. I think you removed those python libraries that are required to update/used in other ....to remove these error you have to add/restore those libraries or reinstall python.

Could not run jupyter on Mac OS (gives pysqlite2 errror)

I have installed anaconda in mac os sierra. Simple python scripts run fine. However, when I try to run jupyter-notebook it fails.
The error message is following:
Traceback (most recent call last):
File "/Users/poudel/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 10, in <module>
import sqlite3
File "/Users/poudel/anaconda3/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/Users/poudel/anaconda3/lib/python3.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: dlopen(/Users/poudel/anaconda3/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-darwin.so, 2): Symbol not found: _sqlite3_enable_load_extension
Referenced from: /Users/poudel/anaconda3/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-darwin.so
Expected in: /usr/lib/libsqlite3.dylib
in /Users/poudel/anaconda3/lib/python3.6/lib-dynload/_sqlite3.cpython-36m-darwin.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/poudel/anaconda3/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
File "/Users/poudel/anaconda3/lib/python3.6/site-packages/notebook/notebookapp.py", line 79, in <module>
from .services.sessions.sessionmanager import SessionManager
File "/Users/poudel/anaconda3/lib/python3.6/site-packages/notebook/services/sessions/sessionmanager.py", line 13, in <module>
from pysqlite2 import dbapi2 as sqlite3
ModuleNotFoundError: No module named 'pysqlite2'
I checked the dylib file, but it is there. What's wrong here?
Bhishan:ls /usr/lib/libsqlite3.dylib
/usr/lib/libsqlite3.dylib*
Similar problems:
No module named _sqlite3
But they did not solve my problem.
Your problem is most likely due to several python envirionments.
Check this question.
Also this question maybe relevant.
Also try to see all installed packages with conda.
I have faced the same issue.
For me installing sqlite via brew solved the issue.
brew install sqlite

Categories