0

I have two Python settings in my machine. One is Python 2.7.6 coming with Enthought Canopy, and is the 2.7.9 file I have downloaded from Python website.

I tried to install Whoosh in both of them. It went fine. In Enthought I have installed it as pip install whoosh given in the following command prompt, Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Admin>

I was trying to practice examples given in https://pythonhosted.org/Whoosh/quickstart.html#a-quick-introduction in both.In the IDLE of Python 2.7.9 it ran fine, but in the IDLE of Python 2.7.6 of Enthought it is giving error as,

Python 2.7.6 | 64-bit | (default, Sep 15 2014, 17:36:35) [MSC v.1500 64 bit (AMD64)] on win32
    Type "copyright", "credits" or "license()" for more information.
    >>> import whoosh
    >>> from whoosh.index import create_in
    >>> from whoosh.fields import *
    >>> schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT)
    >>> ix = create_in("index", schema)

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    ix = create_in("index", schema)
  File "C:\Users\Admin\AppData\Local\Enthought\Canopy\User\lib\site-packages\whoosh\index.py", line 102, in create_in
    return FileIndex.create(storage, schema, indexname)
  File "C:\Users\Admin\AppData\Local\Enthought\Canopy\User\lib\site-packages\whoosh\index.py", line 425, in create
    TOC.create(storage, schema, indexname)
  File "C:\Users\Admin\AppData\Local\Enthought\Canopy\User\lib\site-packages\whoosh\index.py", line 605, in create
    for filename in storage:
  File "C:\Users\Admin\AppData\Local\Enthought\Canopy\User\lib\site-packages\whoosh\filedb\filestore.py", line 81, in __iter__
    return iter(self.list())
  File "C:\Users\Admin\AppData\Local\Enthought\Canopy\User\lib\site-packages\whoosh\filedb\filestore.py", line 518, in list
    files = os.listdir(self.folder)
WindowsError: [Error 3] The system cannot find the path specified: 'index/*.*'
>>> 

I tried to find a solution from the web and tried to fix the Pythonpath.

But as I set it the IDLE of 2.7.6 did not open at all.

Please suggest how may I fix it.

I am opening IDLE standard way, Start>All Programs>IDLE(Python GUI) for 2.7.9 and Start>All Programs>Enthought Canopy(64-bit)>IDLE(64-bit).

I am setting PYTHONPATH as Start>Computer right click from there Advanced System Settings, here Advanced tab, then Environment Variables.

  • More details needed: (1) Full error traceback; (2) Exactly how did you install whoosh? (3) Exactly how are you starting IDLE? (4) What are you doing to the PYTHONPATH which IIUC blocks IDLE from opening? – Jonathan March Mar 25 '15 at 14:55
  • My answers may not fit here, so I am editing the questions. – SUBHABRATA BANERJEE Mar 26 '15 at 06:45
  • You have not specified what changes you made to PYTHONPATH. Nonetheless it seems that a response is now possible, so I'll do that. – Jonathan March Mar 26 '15 at 16:14

1 Answers1

0

When you specify a directory as you do with "index", that is usually relative to the "Current directory". A python script should never make any assumptions about what directory is the current directory when it is started. Instead, you should specify full directory path (typical best practice), or change the current directory explicitly in your script if needed (good practice), or at least be clear to change the directory before you run the script (acceptable). I don't know where your "index" directory is, but assuming that it is in the same directory as your script, then the easiest solution is to tell Canopy to "Change to the editor directory" when the script is in the editor. This command is in the dropdown at the top of the Python panel. You can also use the IPython magic %cd command to change the current directory before you run the script.

Jonathan March
  • 5,800
  • 2
  • 14
  • 16
  • Thank you for your kind answer. I would surely try your answer. When one is running, I am slightly less worried but problems have to be fixed and if it is such a nice help. I will try and get back to you. – SUBHABRATA BANERJEE Mar 27 '15 at 07:22
  • Sir, I tried slightly different way. I had another machine where I was getting the same issue. I fixed there as if not os.path.exists("indexdir"): os.mkdir("indexdir") this fix seems going fine. and in the machine I reported this solution did not work. I prefixed this with >> os.chdir("/tmp/"). Seems going fine. Are they okay? – SUBHABRATA BANERJEE Mar 30 '15 at 08:32