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 9117383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:53:06+00:00 2026-06-17T04:53:06+00:00

I want to do some scripting in python with pydev. The problem that I

  • 0

I want to do some scripting in python with pydev.
The problem that I have is that I can’t start the console in the project directory where the script is, the console starts in the pydev/aptana folder (somewhere in the aptana folder).

I can solve these adding the following code to my script:

import os
import inspect
filename = inspect.getframeinfo(inspect.currentframe()).filename
curpath = os.path.dirname(os.path.abspath(filename))
os.chdir(curpath)

Does somebody know how to change the directory of the console to the project position path automatically when started over the pydev Ctrl+Alt+Enter way ?

–EDIT–

Here is my own solution if someone like it more:

import sys; print('%s %s' % (sys.executable or sys.platform, sys.version)) import os;os.chdir([p for p in os.environ['PYTHONPATH'].split(os.pathsep) if ('Aptana Workspace' in p)][0]) pwd()
  • 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-17T04:53:08+00:00Added an answer on June 17, 2026 at 4:53 am

    I used a bit of a hack to get this working. If I understand your question, you want to have the current working directory in the IPython environment set to the directory in which your active file resides. So if you are editing D:/projects/file.py, you want the pwd() command (in IPython) to return D:/projects. This is where the hacked together part of my solution comes from. All my projects are on my D drive, but all the normal python imports come from the install location on my C drive. So the following:

    os.environ['PYTHONPATH'].split(os.pathsep)
    

    results in a list on which only one path is on the D drive which is of my active file’s directory (because of PyDev setting the PYTHONPATH to include the correct directory). If you don’t use the D drive, then there should be some other unique way of identifying which of the paths in that list pertains to your projects (like in Documents or My Documents, etc.). If there isn’t a way of uniquely identifying your project path, then this answer doesn’t work. But in the simple case of “D:/” being enough of a unique identifier, this is my startup code in the settings (Window > Preferences > PyDev > Interactive Console)

    import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
    import os;os.chdir([p for p in os.environ['PYTHONPATH'].split(os.pathsep) if p.startswith("D")][0])
    pwd()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script that involves some UI Scripting to target a phone number
I want to learn server-side scripting. Since I know some Python, probably that would
I'm developing a web game in pure Python, and want some simple scripting available
I want to use vbscript (or some scripting language I can run locally on
In my asp.net application I have a some client side scripting that alters the
i am new in ssrs i want some sugeestiion from You can i use
i am learning python.. i want to do certain kind of scripting in python..
I have a C application and I want to include a Scripting Language to
I have a very basic problem. I am learning my first steps with python
I want to know what are the options to do some scripting jobs in

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.