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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:46:08+00:00 2026-05-28T14:46:08+00:00

The entry for sys.path[0] is ‘/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode’ . The Python docs say this should be

  • 0

The entry for sys.path[0] is '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode'. The Python docs say this should be the working directory of the script. Any idea what could be going on?

When I run Python from the interactive interpreter and do import sys; print sys.path[0]; it prints '' which seems to be right.

But when my Python script is called from a perl script I get the above entry for sys.path[0].

Other info:

  • I’m running Python 2.7.
  • I’m on Ubuntu 11.10 64 bit.
  • My working directory should be /mnt/galaxyData/custom/MSG_toy
  • The perl script and the python script it’s calling are located in /mnt/galaxyData/custom/MSG_toy/msg (That msg directory is a symbolic link if it matters)

Here is everything on sys.path:

['/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode',
 '/mnt/galaxyData/custom/msg',
 '/usr/local/lib/python2.7/dist-packages/bx_python-0.7.1-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/pip-1.0.2-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/amqplib-1.0.2-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/BeautifulSoup-3.2.0-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/boto-2.1.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/Fabric-1.3.2-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/ssh-1.7.9-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/ipython-0.11-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/Logbook-0.3-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/lxml-2.3.2-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/Mako-0.5.0-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/MarkupSafe-0.15-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/nose-1.1.2-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/numpy-1.6.1-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/Paste-1.7.5.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/PasteScript-1.7.5-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/PasteDeploy-1.5.0-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/python_cjson-1.0.5-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/pyOpenSSL-0.13-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/PyYAML-3.10-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/Routes-1.12.3-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/simplejson-2.2.1-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/Sphinx-1.1.2-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/docutils-0.8.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/Jinja2-2.6-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/Pygments-1.4-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/WebHelpers-1.3-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/WebOb-1.2b2-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/xlrd-0.7.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/Cython-0.15.1-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/Pyrex-0.9.9-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/virtualenv-1.6.4-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/tornado-2.1.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/Twisted-11.0.0-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/biopython-1.58-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/celery-2.4.2-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/pysam-0.5-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/python_dateutil-1.5-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/kombu-1.4.3-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/anyjson-0.3.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/DendroPy-3.9.0-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/HTSeq-0.5.3p3-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/networkx-1.5-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/pandas-0.5.0-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/pygr-0.8.2-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/pysparse-1.2_dev-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/rpy2-2.2.4dev_20111114-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/rpy2_bioconductor_extensions-0.2.5_dev-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/scikits.learn-0.8.1-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/scikits.statsmodels-0.3.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/scipy-0.10.0-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/sympy-0.7.1-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/CouchDB-0.8-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/h5py-2.0.1-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.3-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/pymongo-2.0.1-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/pysqlite-2.6.3-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/psycopg2-2.4.2-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.7.3-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/gnuplot_py-1.8-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/PIL-1.1.7-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/pydot-1.0.25-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/pyparsing-1.5.6-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/pygooglechart-0.3.0-py2.7.egg',
 '/usr/local/lib/python2.7/dist-packages/reportlab-2.5-py2.7-linux-x86_64.egg',
 '/usr/local/lib/python2.7/dist-packages/bcbio_nextgen-0.3a-py2.7.egg',
 '/mnt/galaxyData/custom/bin/python_libs',
 '/mnt/galaxyData/custom/MSG_toy',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-linux2',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/PIL',
 '/usr/lib/python2.7/dist-packages/gst-0.10',
 '/usr/lib/python2.7/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.7',
 '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
 '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
  • 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-05-28T14:46:09+00:00Added an answer on May 28, 2026 at 2:46 pm

    This should do it:

    import os; print(os.path.dirname(__file__))
    

    Cred to @AndiDog.

    EDIT: Also mind the hints in the documentation (here and here) on the availability and value of __file__:

    Predefined (writable) attributes: __name__ is the module’s name; __doc__ is the module’s documentation string, or None if unavailable; __file__ is the pathname of the file from which the module was loaded, if it was loaded from a file. The __file__ attribute is not present for C modules that are statically linked into the interpreter; for extension modules loaded dynamically from a shared library, it is the pathname of the shared library file.

    __file__ is set to the name provided by the module loader. If the loader does not make filename information available, this variable is set to None.

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

Sidebar

Related Questions

I had always assumed that the first entry in sys.path by default was the
#!/usr/bin/env python import os, sys, subprocess, time while True: print subprocess.call(xsel, shell=True); time.sleep(1); Takes
Standard Entry Sequence : _function: push ebp ;store the old base pointer mov ebp,
From the wikipedia entry on NP-Complete: The easiest way to prove that some new
Parser Error Message: The entry 'SiteSqlServer' has already been added. Source Error: Line 23:
I want to restrict entry of new item into sharepoint calendar list with the
I have a single entry output from a paradox table which is imported into
So the Wikipedia entry on Lambda Calculus was interesting but I've finished it. I
On our main data entry screen, we have an OK/Cancel dialog in the OnBeforePost
In the wikipedia entry Unobtrusive JavaScript there is an example of obtrusive JavaScript: <input

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.