0

Here is my folder tree in Windows 10 x64, I am using conda python (3.9.16) and Sphinx 6.1.3 :

├───TradeTracker
│   ├───docs
│   │   ├───_build
│   │   │   ├───doctrees
│   │   │   └───html
│   │   │       ├───_sources
│   │   │       └───_static
│   │   │           ├───css
│   │   │           │   └───fonts
│   │   │           └───js
│   │   ├───_static
│   │   └───_templates
│   └───tradetracker
│       ├───logs
│       │   └───__pycache__
│       ├───store
│       │   ├───archive
│       │   └───__pycache__
│       ├───summary
│       │   ├───archive
│       │   └───__pycache__
│       ├───to_import
│       │   ├───originals
│       │   ├───TWStatements_reference
│       │   └───__pycache__
│       └───__pycache__

my basedir is being set in the conf.py file under /docs and when printed from there resolves to: "C:\Users\admin\Documents\Python\TradeTracker\tradetracker"

my main code file is tradetracker.py which is in that basedir

Calls from within the code look like this tw_csvimport = './to_import/twimport.csv' and work fine to locate all the subfolders such as that one from the code when run normally.

but when I run Sphinx, it is giving these errors...

File "C:\Users\admin\Documents\Python\TradeTracker\tradetracker\tradetracker.py", line 432, in <module>
dfin = read_csv_to_dataframe(tw_csvimport, converters={'Value': lambda x: pd.to_numeric(x.replace(',', ''), errors='coerce')})
File "C:\Users\admin\Documents\Python\TradeTracker\tradetracker\tradetracker.py", line 82, in read_csv_to_dataframe
dfin = pd.read_csv(csv_file_path, converters=converters)
FileNotFoundError: [Errno 2] No such file or directory: './to_import/twimport.csv'

I have been mucking about with various configurations in conf.py but its always the same issue, the current conf.py has:

basedir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'TradeTracker', 'tradetracker'))

sys.path.insert(0, basedir)

It does work if I change the code in tradetracker.py to the full paths "C:\Users...." but that is a bodge approach, I want to know how to resolve this properly.

I did something when mucking about that made it resolve to the to_import folder and other subfolders, but when it did that, it then failed to find the module tradetracker.py and threw that error instead. I do not recall what I did.

I went through suggestions in this post adding in __init__.py to all folders and restructuring the paths, but that hasnt worked for me either.

At this point I am stumped. Even chatGPT is stumped and keeps repeating the same solutions.

EDIT: I am giving up on this ever being solved after finding this article which explains how the error messages can imply there are other code issues and not related to the modules at all. Without more informative error messages I have no hope of tracking down the root cause.

mdkb
  • 372
  • 1
  • 14

0 Answers0