WebFaction
Community site: login faq

I uploaded a python file which includes following lines..

import os, sys, time, urllib, cgitb -> This works fine But, import commonFunc (I have a file named 'commonFunc.py' in the same folder.) -> This line fails with the message, 'ImportError: No module named commonFunc'.

But, both files are all in the same folder and as we already know.. Python searches 'the directory where Python is executed' first. It should work without considering pythonpath.

Why isn't this working??

asked 19 Jan '12, 10:33

namush
1122
accept rate: 0%


I solved it by simply adding the path of the current directory. It didn't work with os.getcwd() so that I just typed the absolute path as string. sys.path.append(my_current_directory)

permanent link

answered 19 Jan '12, 12:58

namush
1122
accept rate: 0%

Glad you were able to solve this, but it's strange that you ran into this problem. If it happens again, please open a support ticket and we'll be happy to take a closer look.

(19 Jan '12, 14:35) seanf
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×27

question asked: 19 Jan '12, 10:33

question was seen: 14,563 times

last updated: 19 Jan '12, 14:35

                              
WEBFACTION
REACH US
SUPPORT
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM