Search code examples
pythonpython-3.xpycharmgetcwdlistdir

pycharm os.listdir does not list contents


I am a SO virgin. Treat me gently.

In Python3.5 I can run:

import os
os.listdir('C:/Users/Tim0t_000/Desktop/python automate boring downloads')

and this produces the list of files contained in that directory.

If I run the same script in Pycharm, it exits without producing the list of files. (exit code 0).

This is the simplest manifestation of the problem.

I've tested Python and Pycharm for the current working directory contents and same pattern.

I looked at the working directory problems highlighted on SO. Solutions to specify the working directory in Pycharm's python console and project structure Source Folder have not worked for me. I have even re-installed Pycharm.

This must be a simple one to fix? Grateful for any suggestions. Its Pycharm community 2016.2.3 on Win10.


Solution

  • Because pycharm does not print expressions results like interactive shell does

    dir_info = os.listdir('C:/Users/Tim0t_000/Desktop/python automate boring downloads')
    print(dir_info)