How to solve this ModuleNotFoundError: No module named '_sqlite3' in docker-debian - python-3.x

While trying to run scrapy spider in docker-debian every time I get an error:
File "/usr/local/lib/python3.6/site-packages/scrapy/crawler.py", line 82, in
crawl
yield self.engine.open_spider(self.spider, start_requests)
builtins.ModuleNotFoundError: No module named '_sqlite3'
python version 3.6.3
scrapy 1.6.0
tried instruction from this post - ImportError: No module named '_sqlite3' in python3.3
still see this error.
when type sqlite3 command in terminal it shows sqlite3 version and start sqlite terminal.
SQLite version 3.16.2 2017-01-06
when type python and write next command in terminal:
import sqlite3
get this error:
ModuleNotFoundError: No module named '_sqlite3'
is there any way to solve this problem? looks like there is some misconfiguration but I can't find where it's

I have the same error with sqlite3 while I was trying to start my crawler using scrapy crawl my-crawler, after some searches and tried out different solutions, I found this answer useful to my error. Just remember that you need to download your specific python version, mine was 3.8.1 and it worked thanks to their answer. I have already install sqlite3 using sudo apt install libsqlite3-dev. Hope it works in your case, too. So, at first install it then reconfigure your python via instructions in the link.

I had same problem in centos, I just fix it. I install multiple python version in pyenv, so I switch the python version from 3.6 to 3.4.1, then problem solved.Maybe the problem was caused by pyenv,or it's python version's problem. If you don't have pyenv,maybe you need to reinstall python,or install a diffrent version of python.Hope be helpful.

Related

Why am I getting ModuleNotFoundError: No module named 'dpkt'?

When I run
import dpkt
It gives
ModuleNotFoundError: No module named 'dpkt'
But I already installed dpkt.
install dpkt cmd
Does anyone know how I can fix this?
I am using window10, python3.
I had the same issue today. I found out that when I installing the dpkt module, it was getting installed onto an environment different than the one I was using in pyCharm.
I found the answer to this post very helpful to explain my issue: https://stackoverflow.com/a/52608375/2411380
I fixed my issue by using the terminal inside pyCharm to install dpkt, then it worked.
I also found a suggestion to use all packages installed in conda inside pyCharm: https://stackoverflow.com/a/49097897/2411380

ModuleNotFoundError: No module named 'zope.deprecation'

Okay, I have lost a day in debugging the script and now I don't have any other option to post a question on StackOverflow. I have a python script which installs Apache Airflow on the machine using a requirement.txt file nothing rocket science simply
sudo pip3 install -r requirement.txt
The problem is during installation I am getting an exception
ModuleNotFoundError: No module named 'zope.deprecation'
at a line which is trying to execute following statement
from airflow.models.variable import Variable
The script has three stages
First: It updates the OS using somewhat apt-get update and also installs some system libraries
Second: It invokes airflow initdb etc
Third: It actually tries to create some specific entries in airflow meta-database, and Its here in this stage I am invoking the statement from airflow.models.variable import Variable which throws an exception
I install all dependencies in stage First so the Module zope.deprecation is also installed via requirement.txt file. The module is there in site-packages folder but It doesn't get imported and throws an exception
I know there are already 7700+ question with title ModuleNotFoundError on StackOverflow and I don't declare that I checked out them all but I did my homework and tried various solutions but none are working for me, Few links I checked out are below
adding directory to sys.path /PYTHONPATH
Unable to import a module that is definitely installed
Python: Installed a local package with pip3, but got module not found error
I can't share the code because of policy issues, but I hope you guys understand.
Any help would be appreciated!
there is a error by zope and zope.deprecation.
you can do this:
pip uninstall zope
pip uninstall zope.deprecation
and then:
pip install zope.deprecation

Unable to use gitpython ImportError

Tried to run a script I wrote yesterday again today and ran into this:
ImportError: cannot import name 'Repo' from 'git' (/usr/local/lib/python3.7/site-packages/git/__init__.py)
I am at a complete loss. On a new computer so the only thing different install wise would have been that I installed pycharm. I am currently trying to run through bash shell on a mac. The exact code was running as excepted earlier, no code changes.
Things I have tried:
uninstalling/reinstalling python
uninstalling/reinstalling pip
uninstalling/reinstalling gitpython
Running on:
mac catalina
python version 3.7.6
pip version 20.0.1
As a side note, the script works as intended until the automated git push. Wondering if I should just make the os calls myself and not worry about this?
I really dont understand what I did/am doing wrong here.
EDIT:
Again, sorry as this is my first mac computer. I did a brew uninstall of python3 and reinstalled through the app store to 3.8.
ImportError: cannot import name 'is_cygwin_git' from partially initialized module 'git.util' (most likely due to a circular import) (/Library/Frameworks/Python.framework/
I know cygwin is for windows, but I figured I'd play along and trying a pip install pycygwin.
Install threw an error asking for cython, so I did another pip install and tried again. The pycygwin then complained gcc was missing so I did a brew install of gcc. With gcc installed and correctly on path, it still says it cant find it and exits with
build/cygwin/_cygwin.c:611:10: fatal error: 'sys/cygwin.h' file not found
#include <sys/cygwin.h>
^~~~~~~~~~~~~~
1 error generated.
error: command 'gcc' failed with exit status 1
Thinking I might just try a different package manager? Currently, an attempt to rerun the script yeilds
ImportError: cannot import name 'Repo' from partially initialized module 'git' (most likely due to a circular import)
To which I investigated but I shouldn't have any overlapping dependancies.
On the script throwing the error I'm using:
import csv
import yaml
import os
from git import Repo
and on the wrapper I made and imported, I'm using:
import subprocess
import re
Will update if I get any further on this, would love some suggestions.
EDIT:
Importing using just import git works throws a different error, like the python is trying to get itself?
ImportError: cannot import name '<file name>' from '<file name>'
If I change the file name and try to run it, it comes backs with:
ImportError: cannot import name '<old file name>' from '<old file name>'
***FIXED****
Uninstall of python through homebrew
Reinstall of python through mac app store
Uninstall/Reinstall of modules through pip
Saving the file under a new name and deleting the old one
Still have absolutely no idea why/how this happened but the above worked for me. If anyone knows why something like this can happen, I would love to know. Cheers.

IPython Notebook showing `ImportError`

I am using Ubuntu 15.04 and I just installed IPython 4.0.
Now, when I type ipython notebook in the terminal, I get the following error message:
ImportError: No module named notebook.notebookapp
I have read related questions on this site but I could not solve this situation.
Since, I have no working knowledge of IPython,so I could really use some advice to fix this.
Try pip install "ipython[notebook]"
and take a look here:
http://ipython.org/install.html#i-already-have-python.
This should install all the dependencies and get you up and running.

psycopg2 import error due to failure to load libraries

I have tried many ways of installing psycopg2 after having installed PostgreSQL using the one-click installer, but anyway I try confronts me with the same import error in python: ImportError: dlopen(/Library/Python/2.5/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libpq.5.dylib
Referenced from: /Library/Python/2.5/site-packages/psycopg2/_psycopg.so
Reason: image not found
I am on Mac OS X 10.5.8. I am using Python 2.5. I installed PostgreSQL from the installer (I did not port it) and it installed in /Library). I added /Library/PostgreSQL/9.1/bin to the setup.cfg of the source psycopg2, as instructed in the INSTALL file and everywhere on the internet and then ran sudo python setup.py build and then sudo python setup.py install.
I also tried exporting /Library/PostgreSQL/9.1/bin to my path instead and running sudo pip install psycopg2. But the exact same problem occurred in all of these scenarii.
I would greatly appreciate some help with this.
Best
Marion
The problem is that at runtime the libpq.5.dylib file can't be found because it is not in one of the default locations searched by the dynamic (runtime) linker. Try to define the environment variable DYLD_LIBRARY_PATH before launching python. I am no MacOS X expert but something like:
export DYLD_LIBRARY_PATH=/Library/PostgreSQL/9.1/lib
will probably work.

Resources