Python Forum
make sys.path.append auto detect
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
make sys.path.append auto detect
#3
(Sep-06-2017, 09:18 PM)SquareRoot Wrote: Hi,

So D:\AvosLab\digital_scale\python is the directory where the python file is saved?

If so, you can get the directory where the python file is saved with

import os
print(os.path.dirname(os.path.realpath(__file__)))
Greetings

yes, it is.
so, can I write it like this?

sys.path.append(os.path.dirname(os.path.realpath(__file__)))
but, what I get on jython is..

Error:
Exception in thread "AWT-EventQueue-0" Traceback (most recent call last): File "python/BPB.py", line 5, in <module> sys.path.append(os.path.dirname(os.path.realpath(__file__))) NameError: name '__file__' is not defined
Reply


Messages In This Thread
make sys.path.append auto detect - by dwiga - Sep-04-2017, 07:45 AM
RE: make sys.path.append auto detect - by dwiga - Sep-07-2017, 12:39 AM

Forum Jump:

User Panel Messages

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