Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Karim Newsgroups: comp.lang.python Subject: Re: Path problems when I am in bash Date: Wed, 30 Dec 2015 03:30:24 +0100 Lines: 86 Message-ID: References: <09513926-226a-4099-a9d4-775ba4b09beb@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de x5ZKonmVU+L+UTeou0rzKQoA560bk18FxpF+0GLxRYtA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '"""': 0.05; 'paths': 0.05; 'skip:" 60': 0.05; 'matches': 0.07; 'cc:addr:python-list': 0.09; 'skip:` 30': 0.09; 'subject:problems': 0.09; 'python': 0.10; 'def': 0.13; 'skip:p 40': 0.15; '(list)': 0.16; '(source': 0.16; '[1].': 0.16; '[5]': 0.16; 'mailinglist': 0.16; 'medusa': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'skip:" 70': 0.16; 'skip:/ 50': 0.16; 'skip:/ 70': 0.16; 'subject:when': 0.16; 'tests)': 0.16; 'wrote:': 0.16; 'skip:` 20': 0.18; 'tests': 0.18; 'input': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'fine,': 0.22; 'cc:no real name:2**0': 0.22; 'import': 0.24; '(most': 0.24; 'header:In-Reply-To:1': 0.24; 'header': 0.24; 'header:User-Agent:1': 0.26; 'skip:" 20': 0.26; 'skip:m 30': 0.27; 'error': 0.27; 'question': 0.27; '[2]': 0.27; 'this.': 0.28; '(my': 0.29; 'environment': 0.29; 'code': 0.30; 'skip:g 30': 0.30; "can't": 0.32; '[1]': 0.32; 'run': 0.33; 'source': 0.33; 'traceback': 0.33; 'message-id:@gmail.com': 0.34; 'structure': 0.34; 'file': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'done': 0.35; 'dir': 0.35; 'path': 0.35; 'skip:" 50': 0.35; 'received:74.125.82': 0.35; 'skip:p 30': 0.35; 'unit': 0.35; 'but': 0.36; 'skip:m 40': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'skip:p 20': 0.38; 'why': 0.39; 'test': 0.39; 'received:192': 0.39; 'hello,': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'export': 0.63; 'here': 0.66; 'prompt': 0.79; 'correctly?': 0.84; 'precompiled': 0.84; 'ranking': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=j899spHhSYwLvrmVqo6VcCxlQwFVZRAoSNl5bo4gnKQ=; b=abhufgByD5uJMhM27zM4h9kX2kFsqJcC9Va1ygcudHiYIIxoxgfeso4JDndy5cBSmQ J4TUG7l57zrfrY+QOvvngRliBqLnZa4Oy23+s/SvE22x/V0Sh5uq2r/YVJIR+3EPMQOz G/0/UjCtw0tuIFCoHQRM+NzTZa9ExJg+Q9FWIQy0Q3z63JJ3+ThAQEpgxXQp45JH+iLL Z0GYYvcNV89bMuXsKoLJfOhB+vkQ9W5lMrCuqq+RdD9qQWTO/NrlBKPwG7y2G3ED+W3W f19jWAnR14htROX4gNLKUvRSWMi4/pBmmAbtUb51hnONvwzj5s2YApbKNg+HGVALpn6w nJ+w== X-Received: by 10.28.24.140 with SMTP id 134mr71026645wmy.34.1451442626455; Tue, 29 Dec 2015 18:30:26 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 In-Reply-To: <09513926-226a-4099-a9d4-775ba4b09beb@googlegroups.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100978 On 30/12/2015 00:21, xeon Mailinglist wrote: > I have my source code inside the directory `medusa`, and my unit tests inside `tests` dir. Both dirs are inside `medusa-2.0` dir. Here is my file structure [1]. > > When I run my tests inside pycharm, everything works fine, but when I try to run my unit tests inside in the prompt [2], the `scheduler/predictionranking.py` can't find the `hdfs` import [3]. I have set my environment inside the `medusa-2.0` dir with the virtualenv, I even have set `medusa-2.0` in the PYTHON_PATH [4]. The error that I have is in [5]. > > The question is, why the import is not being done correctly? > > > [1] My file structure > > medusa-2.0$ > medusa (source code) > hdfs.py > scheduler (dir with my schedulers) > predictionranking.py > tests (my unit tests) > > > [2] I run the unit test like this. > > medusa-2.0$ python -v tests/testSimpleRun.py > > > [3] The header in `predictionranking.py` > > import hdfs > > def get_prediction_metrics(clusters, pinput): > """ > :param pinput (list) list of input paths > > """ > > input_size = hdfs.get_total_size(pinput) > > [4] My python path > > export MEDUSA_HOME=$HOME/repositories/git/medusa-2.0 > > export PYTHONPATH=${PYTHONPATH}:${MEDUSA_HOME}/medusa > > [5] error that I have > > medusa-2.0$ python -v tests/testSimpleRun.py > # /home/xeon/repositories/git/medusa-2.0/medusa/local.pyc matches /home/xeon/repositories/git/medusa-2.0/medusa/local.py > import medusa.local # precompiled from /home/xeon/repositories/git/medusa-2.0/medusa/local.pyc > # /home/xeon/repositories/git/medusa-2.0/medusa/ranking.pyc matches /home/xeon/repositories/git/medusa-2.0/medusa/ranking.py > import medusa.ranking # precompiled from /home/xeon/repositories/git/medusa-2.0/medusa/ranking.pyc > # /home/xeon/repositories/git/medusa-2.0/medusa/decors.pyc matches /home/xeon/repositories/git/medusa-2.0/medusa/decors.py > import medusa.decors # precompiled from /home/xeon/repositories/git/medusa-2.0/medusa/decors.pyc > # /home/xeon/repositories/git/medusa-2.0/medusa/settings.pyc matches /home/xeon/repositories/git/medusa-2.0/medusa/settings.py > import medusa.settings # precompiled from /home/xeon/repositories/git/medusa-2.0/medusa/settings.pyc > import medusa.scheduler # directory /home/xeon/repositories/git/medusa-2.0/medusa/scheduler > # /home/xeon/repositories/git/medusa-2.0/medusa/scheduler/__init__.pyc matches /home/xeon/repositories/git/medusa-2.0/medusa/scheduler/__init__.py > import medusa.scheduler # precompiled from /home/xeon/repositories/git/medusa-2.0/medusa/scheduler/__init__.pyc > # /home/xeon/repositories/git/medusa-2.0/medusa/scheduler/predictionranking.pyc matches /home/xeon/repositories/git/medusa-2.0/medusa/scheduler/predictionranking.py > import medusa.scheduler.predictionranking # precompiled from /home/xeon/repositories/git/medusa-2.0/medusa/scheduler/predictionranking.pyc > Traceback (most recent call last): > File "tests/simpleRun.py", line 4, in > from medusa.simplealgorithm import run_simple_execution > File "/home/xeon/repositories/git/medusa-2.0/medusa/simplealgorithm.py", line 8, in > import accidentalfaults > File "/home/xeon/repositories/git/medusa-2.0/medusa/accidentalfaults.py", line 5, in > import hdfs > File "/home/xeon/repositories/git/medusa-2.0/medusa/hdfs.py", line 6, in > from system import execute_command > File "/home/xeon/repositories/git/medusa-2.0/medusa/system.py", line 10, in > from ranking import rank_clusters > File "/home/xeon/repositories/git/medusa-2.0/medusa/ranking.py", line 9, in > from scheduler.predictionranking import get_prediction_metrics > File "/home/xeon/repositories/git/medusa-2.0/medusa/scheduler/predictionranking.py", line 6, in > import hdfs Hello, Can you try to set your PYTHONPATH like that: export PYTHONPATH=${PYTHONPATH}:${MEDUSA_HOME} Regards Karim