473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

execute python script question

Hello,

I have been developping something in python that has the following
hierarchy :

project/src/myPackage/
project/src/myPackage/__init__.py
project/src/myPackage/module1.py
project/src/myPackage/module2.py
project/src/myPackage/test/
project/src/myPackage/test/__init__.py
project/src/myPackage/test/test_module1.py
project/src/myPackage/test/test_module2.py
project/src/myPackage/mySubPackage/__init__.py
project/src/myPackage/mySubPackage/module1.py
project/src/myPackage/mySubPackage/test/
project/src/myPackage/mySubPackage/test/__init__.py
project/src/myPackage/mySubPackage/test/module1.py
....

up until now, I had been executing my modules from inside
project/src/myPackage/
but I realised that that is wrong (while implementing the test suite)
and that since all my modules had relative imports (if module2 needed
module1, it would just say : import module1) I changed them to
myPackage.module1 for example. Now my test suite is happy, I can say :
test.sh myPackage.test and it tests everything. The only problem now is
that I can't execute the scripts from inside or outside the myPackage
dir, I get this :

from outside :

Traceback (most recent call last):
File "myPackage/module1.py", line 15, in <module>
from myPackage import constants, utils
ImportError: No module named myPackage

or if from inside it :

Traceback (most recent call last):
File "module1.py", line 15, in <module>
from myPackage import constants, utils
ImportError: No module named myPackage

can anybody please help me? I don't think I understood the whole
package/module thing I think... I think some people do some sort of
importing in the __init__.py files but I'm not sure this helps in this case.

Thanks,
Gabriel

--
www.mydeskfriend.com
PSE - C (EPFL)
1015 Ecublens, Switzerland
Tel: +41 21 601 52 76
Mob: +41 76 442 71 62

Mar 10 '08 #1
0 1097

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: somialis | last post by:
I have a test environment in python. it is executed by the following command on the command prompt. 1) First i have to go to the dir where the .py file is 2) then i simply execute python...
5
by: johnny | last post by:
Anyone know how I can make Machine A python script execute a python script on Machine B ?
4
by: brad | last post by:
When I use idle or a shell to execute a python script, the script executes in the directory it is currently in (in this case, my desktop). However, when using GNOME and right clicking the py script...
3
by: joe jacob | last post by:
I configured apache to execute python scripts using mod_python handler. I followed below mentioned steps to configure apache. 1. In http.conf I added <Directory...
0
by: srinivasan srinivas | last post by:
This is ok. Is there any other way to find it out? Thanks, Srini ----- Original Message ---- From: Gerhard Häring <gh@ghaering.de> To: python-list@python.org Sent: Friday, 20 June, 2008...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.