Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8587011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:27:39+00:00 2026-06-11T22:27:39+00:00

I am working on code that uses os.walk to search through a relative path.

  • 0

I am working on code that uses os.walk to search through a relative path. When I run it as a python script I have no problems but after converting it to an exe it can’t seem to find the relative path. The current path prints fine Below is the current solution that i have been working on.

if getattr(sys, 'frozen', False):
    currentPath = os.path.dirname(sys.executable)
    relativePath = os.path.join(currentPath,'/../../folder')
else:
    currentPath = inspect.stack()[0][1]
    relativePath = os.path.join(currentPath,'/../../folder')

for root, dirs, files in os.walk(relativePath):

When hardcoding the relativePath the exe works.

relativePath = “D:/location/../../folder”

Is there something tricky with joining when converting to an exe that I’m missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:27:41+00:00Added an answer on June 11, 2026 at 10:27 pm

    I’m not sure but the cause could be that you are mixing backslashes and forward slashes in the path.

    Try changing the code that creates relativePath to the following:

    relativePath = os.path.join(currentPath, '..', '..', 'folder')
    

    This should ensure that you are definitely using the correct path separator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some working code that uses IImgCtx to load images, but I can't
I'm working on someone's code and they have a constructor that uses: class qwerty
I have recently been tasked to working on code that uses Java CUP. Does
I'm working on a bit of python code that uses mechanize to grab data
I have been working on some legacy C++ code that uses variable length structures
I'm just learning Android. I have working piece of code that uses ContentValues: My
I have some Python code that uses Paramiko to grab build files from a
I have some (working) code that uses a multimap<string,string> . I'd like to change
I've been working with somebody else's code and noticed that on all uses of
I'm working some code that inserts csv rows into an SQLite database using Python.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.