0

when i am importing some modules from python shell, import work fine: for example: (link for propy module https://code.google.com/p/protpy/downloads/list)

>>> import propy
>>>

but when i write script with python Default IDLE or with other IDE and save it to as .py script , import statements not work and generate error like this

python fragment_generator.py

>>> 
Traceback (most recent call last):
  File "J:\acetylome scripts\New folder\fragment_generator.py", line 1, in <module>
    import propy
ImportError: No module named propy
>>> 

please solve it

thanks in advance:

JAZs
  • 29
  • 7
  • 5
    What is `propy` and where is it located? – BrenBarn Oct 21 '13 at 17:58
  • Are you sure the Python you run in the shell is the same interpreter you run in your IDE? And are you relying on propy.py being in the current working directory of the shell, but then running the scripts from a different working directory? – abarnert Oct 21 '13 at 18:01
  • @BrenBarn its a module which i install Biopython is also a module it is also showing same error. i install it and it is install in its defautl path. – JAZs Oct 21 '13 at 18:02
  • @abarnert yes i am running it with Python's default IDLE and defualt shell – JAZs Oct 21 '13 at 18:03
  • How many python interpreters or versions do you have on the system? – Back2Basics Oct 21 '13 at 18:05
  • can you print `sys.path` in both the console, and in the script before the import? – Corley Brigman Oct 21 '13 at 18:13
  • @Back2Basics i have installed python2.5, 2.7 and 3.1 and 3.3, :D – JAZs Oct 21 '13 at 18:21
  • @JAZs: And are you sure you're using the IDLE and command line from the same version? (Also note that unless you're on Windows, you likely already had at least one Python before installing anything. For example, Mac 10.8 comes with 2.5, 2.6, and 2.7, and it's easy to install something for Apple's 2.7 and then not find it in your second 2.7 and not realize there's a problem.) – abarnert Oct 21 '13 at 18:24
  • @abarnert yes i m using python 2.7 shell and IDLE but its showing same error for almost all the modules which i have install after python installation "Protpy" "Biopython" etc :( :( – JAZs Oct 21 '13 at 18:33
  • 1
    @JAZs: You're only answering half the questions people are asking, and ignoring the others. Nobody will be able to debug your code if you won't provide useful information. – abarnert Oct 21 '13 at 23:42
  • Meanwhile how did you install all these modules? Using `pip`? Or some installer in your IDE? Or running Christoph Gohkle's binary installers? Or `python setup.py install`? Or…? Do you have (or can you get, e.g., by repeating the process) the logs from at least one installation so you can verify that the files were installed into the right `site-packages` (that is, into something that's on the right Python's `sys.path`)? – abarnert Oct 21 '13 at 23:44
  • And, backing up a step: Do you realize that each Python installation has its own separate site-packages, so installing a package for your Python 2.5 doesn't make it available in your 3.1? – abarnert Oct 21 '13 at 23:44

1 Answers1

0

When you run the shell from the same directory the files are in the import will work. You are probably working from another directory when the import fails.

you can add a directory to the python path like this.

befor your import:

import sys
sys.path.append('/path/to/your/folder')
import propy

good luck.

Shani
  • 418
  • 2
  • 8
  • Considering that he's trying to use packages he installed, not just local files, this isn't relevant. – abarnert Oct 21 '13 at 23:45