0

I have a file named "generate_tax_report.py" which is stored at location "C:\Users\rites\Desktop\crypto-tax-report\van\adam".

enter image description here

Within file "generate_tax_report.py", I need to import a python script "fifo.py" which is stored at location "C:\Users\rites\Desktop\crypto-tax-report\van\adam\inventory_methods as seen in below image".

enter image description here

I have written:from van.adam.inventory_methods import fifo, but getting error as

File "c:\Users\rites\Desktop\crypto-tax-report\van\adam\generate_tax_report.py", line 13, in <module> from van.adam import transactions as t ModuleNotFoundError: No module named 'van.adam'; 'van' is not a package

Edit: Added structure of van folder: enter image description here

4
  • What does your van directory look like? It should have an __init__.py script. Also, how are you calling generate_tax_report.py? Are you running python generate_tax_report.py? If so, what is your working directory? Commented Jul 17, 2022 at 20:14
  • Hi @ogdenkev , I have edited the question with structure of van directory. I am running python generate_tex_report.py file. My working directory is: C:\Users\rites\Desktop\crypto-tax-report\van\adam" Commented Jul 17, 2022 at 20:40
  • Have you installed van as a package? Commented Jul 17, 2022 at 20:47
  • @ogdenkev I am trying to import python scripts stored with vim\adam\ folder Commented Jul 17, 2022 at 20:50

2 Answers 2

1

Assuming you have not installed van as a package, the problem is that when you run python generate_tax_report.py from Desktop/crypto-tax-report/van/adam, Python does not add Desktop/crypto-tax-report to the path, so from van.adam.inventory_methods import fifo fails because Python does not know about van.

If you moved generate_tax_report.py to Desktop/crypto-tax-report and then ran python generate_tax_report.py from Desktop/crypto-tax-report, it should work.

Alternatively, you could leave everything as you have it set up, but run python -m van.adam.generate_tax_report from Desktop/crypto-tax-report.

Sign up to request clarification or add additional context in comments.

Comments

0

did you try on this

import sys

sys.path.append('C:\\Users\\rites\\Desktop\\crypto-tax-report\\van\\adam\\inventory_methods')

import fifo

worked on windows machine and print variable value in destination file

this is an example of importing it

3 Comments

mo is the file you put his folder location in sys.path.append('C:\\Users\\path to file ')
I tried this, but this is also not working.
I edited the answer for your path could you try it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.