nvdv / vprof

Visual profiler for Python
BSD 2-Clause "Simplified" License
3.95k stars 154 forks source link

FileNotFoundError path to script has spaces #105

Closed Ashesh3 closed 1 year ago

Ashesh3 commented 3 years ago
Description

Running a profiler exits with an exception when the path to the script has a space in it

How to reproduce
  1. Make a python file in C:\Users\test\Desktop\Folder 1\Folder 2\script.py
  2. Now try to run the profiler by vprof -c ph C:\\Users\\test\\Desktop\\Folder 1\\Folder 2\\script.py
  3. Terminates with an exception:
Running CodeHeatmapProfiler...
Traceback (most recent call last):
  File "c:\users\test\appdata\local\programs\python\python38-32\lib\runpy.py", line 193, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\test\appdata\local\programs\python\python38-32\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\test\AppData\Local\Programs\Python\Python38-32\Scripts\vprof.exe\__main__.py", line 7, in <module>
  File "c:\users\test\appdata\local\programs\python\python38-32\lib\site-packages\vprof\__main__.py", line 83, in main
    program_stats = runner.run_profilers(source, config, verbose=True)
  File "c:\users\test\appdata\local\programs\python\python38-32\lib\site-packages\vprof\runner.py", line 73, in run_profilers
    run_stats[option] = curr_profiler.run()
  File "c:\users\test\appdata\local\programs\python\python38-32\lib\site-packages\vprof\base_profiler.py", line 169, in run
    return self.profile()
  File "c:\users\test\appdata\local\programs\python\python38-32\lib\site-packages\vprof\code_heatmap.py", line 217, in profile_module
    return base_profiler.run_in_separate_process(self._profile_module)
  File "c:\users\test\appdata\local\programs\python\python38-32\lib\site-packages\vprof\base_profiler.py", line 77, in run_in_separate_process
    raise exc
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\Users\\test\\Desktop\\Folder'
Actual results

Terminates with a File not found exception as shown above

Expected results

It should be able to profile that script which is in a folder with spaces

Version and platform

vprof 0.38 Windows 10

Zarainia commented 2 years ago

Same issue with arguments with spaces. And unlike with paths you can't just make a link or something to avoid this.