Python Forum
What do you think of this procedure to create a path to a folder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What do you think of this procedure to create a path to a folder
#8
going back to the question of the paths (it has nothing to do with latest error) for db and text files
where do you want to create the database? I may have mislead you when refer to _MEIPASS and I apologise if that is the case

look at the sample script that is provided in the pyinstaller docs
import sys, os
frozen = 'not'
if getattr(sys, 'frozen', False):
        # we are running in a bundle
        frozen = 'ever so'
        bundle_dir = sys._MEIPASS
else:
        # we are running in a normal Python environment
        bundle_dir = os.path.dirname(os.path.abspath(__file__))
print( 'we are',frozen,'frozen')
print('__file__ is', __file__)
print('__file__ abspath is', os.path.abspath(__file__))
print( 'bundle dir is', bundle_dir )
print( 'sys.argv[0] is', sys.argv[0] )
print( 'sys.executable is', sys.executable )
print( 'os.getcwd is', os.getcwd() )
input()
I have it as pypaths.py in c:\sandbox\pypaths.py

Output:
we are not frozen __file__ is c:/sandbox/pypaths.py __file__ abspath is c:\sandbox\pypaths.py bundle dir is c:\sandbox sys.argv[0] is c:/sandbox/pypaths.py sys.executable is C:\Program Files (x86)\Python37-32\python.exe os.getcwd is C:\sandbox
if I freeze it and run the exe from C:\sandbox\pypaths.exe

the output is
Output:
we are ever so frozen __file__ is pypaths.py __file__ abspath is C:\sandbox\pypaths.py bundle dir is C:\Users\***\AppData\Local\Temp\_MEI124082 sys.argv[0] is C:\sandbox\pypaths.exe sys.executable is C:\sandbox\pypaths.exe os.getcwd is C:\sandbox
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: What do you think of this procedure to create a path to a folder - by buran - Sep-04-2019, 10:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to capture the result set from a stored procedure? dee 5 314 May-25-2024, 01:03 AM
Last Post: deanhystad
  Create dual folder on different path/drive based on the date agmoraojr 2 561 Jan-21-2024, 10:02 AM
Last Post: snippsat
  python script is hanging while calling a procedure in database prasanthi417 4 674 Jan-17-2024, 02:33 PM
Last Post: deanhystad
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 681 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  create a default path with idle to a specific directory greybill 0 922 Apr-23-2023, 04:32 AM
Last Post: greybill
  python call stored procedure mg24 2 1,165 Oct-18-2022, 02:19 AM
Last Post: mg24
  python call stored procedure with two parameter mg24 4 1,729 Sep-27-2022, 05:02 AM
Last Post: deanhystad
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,668 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  WebDriverException: Message: 'PATH TO CHROME DRIVER' executable needs to be in PATH Led_Zeppelin 1 2,280 Sep-09-2021, 01:25 PM
Last Post: Yoriz
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,564 Mar-22-2021, 10:59 AM
Last Post: shantanu97

Forum Jump:

User Panel Messages

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