brew: Error while importing sqlite: ImportError: No module named _sqlite3
- Ran
brew updateand retried your prior step? - Ran
brew doctor, fixed as many issues as possible and retried your prior step? - If you’re seeing permission errors tried running
sudo chown -R $(whoami) $(brew --prefix)?
I basically tried everything. Whatever I found online regarding this issue and people were mentioning that it worked I did it… but it doesn’t work for me. For example brew rm python python3 sqlite --force and other things that I could remove I did it… but no luck…
I’m recently updated all of my Homebrew stuff when I upgraded to macOS 10.12… and here is the current situation… is there anything I can try before throwing away this Macbook Pro outside of my window?
$ brew install python sqlite
Warning: python-2.7.12 already installed
Warning: sqlite-3.14.2 already installed
#-----------------------------------------------------------------------------
$ which python
/usr/local/bin/python
#-----------------------------------------------------------------------------
$ find /usr/local -name sqlite
/usr/local/Cellar/sqlite
/usr/local/opt/sqlite
#-----------------------------------------------------------------------------
$ python
Python 2.7.12 (default, Sep 27 2016, 20:06:01)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sqlite
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 28, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 33 (15 by maintainers)
Commits related to this issue
- Removed pointless symlink in brew.sh ``` ln -s /usr/local/bin/gsha256sum /usr/local/bin/sha256sum ``` This is pointless since the non-prefixed version is already in `gnubin` https://github.com/... — committed to lipis/dotfiles by lipis 8 years ago
- .brew.sh: Remove pointless symlink The following is unnecessary: ln -s /usr/local/bin/gsha256sum /usr/local/bin/sha256sum …because the non-prefixed version is already in `$(brew --prefix coreut... — committed to mathiasbynens/dotfiles by lipis 8 years ago
- .brew.sh: Remove pointless symlink The following is unnecessary: ln -s /usr/local/bin/gsha256sum /usr/local/bin/sha256sum …because the non-prefixed version is already in `$(brew --prefix coreut... — committed to mattsearles/dotfiles by mattsearles 8 years ago
That’s weird. Could you please try
to install CLT and try again (
brew update --force; brew uninstall --force python; brew install python)?If that doesn’t work I’ll tell you a secret way.
My personal opinion of cask is it’s pretty awful for any sort of management, but it’s useful for one off installations, and that’s what I use it for. Any cask lovers out there: I do not intend to spark an argument.
It’s fine, but
is pointless since the non-prefixed version is already in
gnubin. Also, you should hard code$(brew --prefix coreutils)/libexec/gnubin(e.g./usr/local/opt/coreutils/libexec/gnubin) to speed up shell init.@zmwangx and now everything is nice and clean! 😃 Can I ask your opinion about
brew cask… I used to have it like a million years ago… is it OK to use it?Something is odd with my machine 😦 thanks man… I installed
pyenvused all the versions from2.7.8 - 2.7.12and I downgraded the App Engine sdk as well… no luck… I’m ready!As you can see, CLT package installs its contents into
/Systemand/usr, both of which are overwritten by a major OS upgrade.Magic! I really can’t believe that it worked 😃 Thank you very very nice…! Spent the whole evening on that… 😃
So the good news is that my machine is very clean and nice…!!
the bad news is that I still have the same error: https://gist.github.com/lipis/946c17457cdd8acf45d6270091ebc63a
If there are any clues above… fine… but in the meantime I’ll try to work on my older machine… and maybe downgrade (somehow) to El Capitan 😦
(Maybe also posting this somewhere else would make sense… I can’t be the only one…)
and I’m also ready to run this beauty:
brew.shany other magic to add or remove?(you can also totally ignore my questions…)
Opened https://github.com/Homebrew/homebrew-core/issues/5347 to see if we can prevent more users from wasting time on Python due to missing CLT.
Now you may try a binary installer from python.org directly but I doubt it would help much…
Huh sorry to hear that but no idea… I myself did run into the “Python quit unexpectedly” issue intermittently since 3.5 I believe (which is roughly the same time as 2.7.11), but it was pretty rare and never reproducible.
I’m sure I had them installed on that machine… as I think Homebrew requires that at one point… but after the Sierra upgrade things went sideways (as always)… thanks again! Cheers… 🍺 🍻 🍺
The secret way is
But
brew install pythonshould really pour the bottle. Guess it’s because you’re missing CLT, but not sure, I’m not familiar with no-CLT configurations.I still want to know the secret way though… in case of trouble in the future I can always come back here…
The beauty of Python! On it…
I just came back to my computer.
Info disagrees.
Judging from your desperateness, you should really consider pouring our bottle instead of trying to debug your source build.
But if you really want to debug your source build, show us your
and the conversation might be able to continue.
Awesome man! Much appreciated…
Maybe also change the first CLT to: Command Line Tools (CLT)
@reitermarkus Let’s see when the new one will overpass it…
And legacy-homebrew is 28. 😂
By the way…! Homebrew is on #43… http://githubstats.lip.is
👍 Good luck with your clean install.
It’s just sucks… but that’s life 😃 When you play dangerous games…
Basically at the moment I’m backing up, committing my 3423 projects into GitHub making sure that 652TB of crap in Dropbox are synced and I’ll be ready to clean the shit out of it… I wanted to do that for quite some time now… so it looks like that day/night just arrived 😃
Or you can try installing just Python in a clean VM.
Unfortunately no, I’m not running into such issues on Sierra, and I doubt it’s our problem (most of my stuff run on Python 3 though, and almost always with a non system wide Python). Maybe you could give pyenv a try?
I might need to throw away this computer (or maybe just have clean install) after all… 😦
Not sure if that’s related but it looks like something is wrong again… that happens every time that I’m trying to deploy the app on App Engine… In case that matters… and yes I deleted every single trace of google-cloud-sdk and installed it again… no luck 😃
Maybe @zmwangx you have some other black magic that could help me…?
Glad to hear.
I don’t care about debugging… I just want to make it work… I thought by running
brew install pythonwould use your bottle 😃 Am I missing something?! How do I override… solve my problem?Used your bottles. Here is the gist to avoid crappy comments.
Did you install python from source? Or did you pour our bottle? Please post of the output of the following commands: