Python 101: Cant open file: No such file or directory

Python 101: Cant open file: No such file or directory

Python cannot access the files in the subdirectory unless a path to it provided. You can access files in any directory by providing the path. python C:Python27Projectshello.py

I resolved this problem by navigating to C:Python27Scripts folder and then run file.py file instead of C:Python27 folder

Python 101: Cant open file: No such file or directory

From your question, you are running python2.7 and Cygwin.

Python should be installed for windows, which from your question it seems it is. If which python prints out /usr/bin/python , then from the bash prompt you are running the cygwin version.

Set the Python Environmental variables appropriately
, for instance in my case:

PY_HOME=C:optPython27
PYTHONPATH=C:optPython27;c:optPython27Lib

In that case run cygwin setup and uninstall everything python.
After that run which pydoc, if it shows

/usr/bin/pydoc

Replace /usr/bin/pydoc
with

#! /bin/bash
 /cygdrive/c/WINDOWS/system32/cmd /c %PYTHONHOME%Scripts\pydoc.bat

Then add this to $PY_HOME/Scripts/pydoc.bat

rem wrapper for pydoc on Win32
@python c:optPython27Libpydoc.py %*

Now when you type in the cygwin bash prompt you should see:

$ pydoc
 pydoc - the Python documentation tool

 pydoc.py <name> ...
   Show text documentation on something.  <name> 
   may be the name of a Python keyword, topic,
   function, module, or package, or a dotted
   reference to a class or function within a
   module or module in a package.
...

Leave a Reply

Your email address will not be published. Required fields are marked *