Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I was trying to batch reproject a set of shapefiles and I kept getting the error No OS Module

As the set was relatively small I just did it individually, however I want to be able to batch process in the future.

How do I correct this problem? Any advice or answers would be greatly appreciated.

Thanks,

Jason

share|improve this question
    
Could you please provide the code and the exact resultant error message? –  Chad Cooper Sep 10 '12 at 14:46
    
A similar question was asked a few days ago: gis.stackexchange.com/questions/32988/… –  sgrieve Sep 10 '12 at 15:12

3 Answers 3

If you were correct writing No OS Module then it is possible that you had used caps letters - it is incorrect. In Python os and OS are different modules and there is no module in standard library named OS.

So, try correcting it to import os.

Another solution is to check your python environment used by ArcGIS. Here is some further discussion on Esri forum. One of solutions from that thread:

SOLUTION: The ntpath.pyc module, necessary for importing the os module, is not in the C:\Program Files\ArcGIS\bin path. To resolve this, if it happens to you, set the PYTHONPATH Environment variable to include the path to the same directory where PythonWin finds the ntuser.pyc module. You can determine this easily by going to the Interactive Window in PythonWin or IDLE and typing: import os; os.path. It will typically be in the following directory C:\Python25\Lib or something like that. Include that path as a value in your PYTHONPATH Environment variable (separate paths with semicolons) and see if this test script will run as a Script Tool in the ArcGIS Toolbox. It should work. It did for me.

Apparently, when running in PythonWin, the loader searches in the same directory where the python.exe is found and doesn't use (need) PYTHONPATH to resolve the reference. When running under the python.exe in the C:\Program Files\ArcGIS\bin it does need PYTHONPATH to resolve the reference. On the other hand, when running in PythonWin, the loader does use the PYTHONPATH Environment variable to resolve the arcgisscripting reference.

Hope it helps you!

share|improve this answer

In terms of the module os error, this sounds like it is a problem with your Python installation, as the OS module is used to perform operating system functions and as such anything you have done in ArcMap should not impact the import of the operating system functions.

share|improve this answer

Check that you can start IDLE and then try to:

import os

If this returns a "No os module" error then your Python installation needs to be checked.

However, if you are using a Python script that you have written to do the batch reprojects then it may be that you have just overlooked putting an "import os" line at the beginning.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.