Trying to wrap my head around changes in import python2 to python3
I have a small app written in python2 (works in 2.7) that I am trying to convert to python3. My version is 3.9.
The main part of the app is in one directory and there are additional modules nested one directory below. The sub-directory is named db. and contains modules Table.py, Column.py, etc. So the relative path is db/Table.py etc. The python2 syntax to import all the modules in the lower directory is "import db" Python3 however gives me an error Code:
import db Any suggestions on how to state that for successful import, or where to look for better info than I have located so far.? |
One of the 2→3 fixes futurize performs on your code is this:
Quote:
|
Quote:
Code:
~/test Code:
import sys A.py Code:
class two(): Code:
python ~/test/__init__.py |
Quote:
My biggest hurdle here is that I did not write the package and am trying to modify this one small part to work under python3.9 I ran futurize on the entire package and it ran cleanly. However, now when I try to run it there is one import from python2 that seems to no longer exist. This error occurs even though my system still has python2.7 installed and functional. Code:
import gtk I feel confident this error is because now the package calls python3 libs instead of the older python2 libs and I need to find the replacement that will work. I still have the functioning python2 version but am really trying to convert it to only python3. Research shows that PyGObject should be the python3 replacement for PyGtk. On my system I have both PyGtk and PyGObject installed but cannot seem to figure out exactly what to import from PyGObject as a replacement for gtk for this use. Any more pointers in this? |
Well, start with Getting Started ;)
Code:
import gi |
All times are GMT -5. The time now is 09:38 AM. |