Python Forum
Having trouble with a circula import
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Having trouble with a circula import
#1
When I try to run the sqlite3 module. It is saying it has a circula import. Here is the error:

line 2, in <module>
    import sqlite3
  File "C:\Users\Chris\Python\Lib\sqlite3\__init__.py", line 37, in <module>
    conn = sqlite3.connect('c:/Users/Chris/Python/Python Projects/mock_database/algo_database.db')
           ^^^^^^^^^^^^^^^
AttributeError: partially initialized module 'sqlite3' has no attribute 'connect' (most likely due to a circular import)
What is going on here?
Reply
#2
It seems to have infected my whole system. No other folders are able to interact with sqlite3.
Reply
#3
(Jul-04-2023, 10:11 PM)SuchUmami Wrote: It seems to have infected my whole system. No other folders are able to interact with sqlite3.
I would hope so. It would be confusing if you only had a problem in certain folders. Now there is only one problem to fix.

It took me a while to see the problem, maybe because it was so unexpected. The error message clearly tells me that you edited this file and broke the sklite3 package:

"C:\Users\Chris\Python\Lib\sqlite3\__init__.py"

You should not edit that file. That file is part of sqlite3. You should not edit any files in the Python distribution. You should write your own programs in files that are not in the Python folder. The programs you write should import modules from the Python distribution.

You might be able to fix the file by removing line 37 from the file:
conn = sqlite3.connect('c:/Users/Chris/Python/Python Projects/mock_database/algo_database.db')
but I'd bet there are other things you changed that make sqlite3 unusable on your system. You probably need to re-install python.

From now on don't mess with anything in the Python folder. After reinstalling Python you should watch some tutorials that show you how to create a virtual python environment to use in your project. Windows doesn't have a "system python", so this is less important than on Linux or Mac. Messing with the "system python" can break parts of the operating system. But even on Windows there will be a lot less confusion in the future if each of your python projects has its own python environment.
ferdnyc likes this post
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trouble with "from…import…as" arbiel 2 2,751 Apr-14-2020, 03:38 PM
Last Post: arbiel
  Import from .py trouble michael1789 4 2,352 Nov-27-2019, 11:23 PM
Last Post: michael1789

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020