Repository: spyder-ide/spyder

Issue:
Crash on profiler because of lack of profiler.results
## Description

**What steps will reproduce the problem?**

1. 
2. 
3. 

**What is the expected output? What do you see instead?**


**Please provide any additional information below**

  File "/home/amitruf/anaconda3/lib/python3.5/site-packages/spyder_profiler/widgets/profilergui.py", line 263, in <lambda>
    self.finished(ec, es))
  File "/home/amitruf/anaconda3/lib/python3.5/site-packages/spyder_profiler/widgets/profilergui.py", line 328, in finished
    self.show_data(justanalyzed=True)
  File "/home/amitruf/anaconda3/lib/python3.5/site-packages/spyder_profiler/widgets/profilergui.py", line 349, in show_data
    self.datatree.load_data(self.DATAPATH)
  File "/home/amitruf/anaconda3/lib/python3.5/site-packages/spyder_profiler/widgets/profilergui.py", line 461, in load_data
    stats_indi = [pstats.Stats(profdatafile),]
  File "/home/amitruf/anaconda3/lib/python3.5/pstats.py", line 72, in __init__
    self.init(arg)
  File "/home/amitruf/anaconda3/lib/python3.5/pstats.py", line 86, in init
    self.load_stats(arg)
  File "/home/amitruf/anaconda3/lib/python3.5/pstats.py", line 99, in load_stats
    with open(arg, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/amitruf/.config/spyder-py3/profiler.results'


## Version and main components

* Spyder Version: 3.2.4 
* Python Version: 3.5.4
* Qt Versions: 5.6.2, PyQt5 5.6 on Linux

## Dependencies
```
pyflakes >=0.6.0 :  1.6.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.20.3 (OK)
numpy >=1.7      :  1.13.3 (OK)
sphinx >=0.6.6   :  1.6.3 (OK)
rope >=0.9.4     :  0.10.5 (OK)
jedi >=0.9.0     :  0.10.2 (OK)
psutil >=0.3     :  5.4.0 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
sympy >=0.7.3    :  1.1.1 (OK)
cython >=0.21    :  0.26.1 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
IPython >=4.0    :  6.1.0 (OK)
pylint >=0.25    :  1.7.4 (OK)

```



Discussion:
Thanks for reporting. We'll fix this problem in our 3.2.5 version.
@rlaverde, please take a look at this one.
I can't reproduce it

@amit-ruf What were you doing when this issue occurred? What steps will reproduce it?
I'm not sure, but I did install jupyter notebook support via this link:
https://github.com/spyder-ide/spyder-notebook
I just removed anaconda completely and reinstall. It solved the problem for
now.

On Fri, Oct 27, 2017 at 6:49 PM, Rafael Laverde <notifications@github.com>
wrote:

> I can't reproduce it
>
> @amit-ruf <https://github.com/amit-ruf> What were you doing when this
> issue occurred? What steps will reproduce it?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/spyder-ide/spyder/issues/5587#issuecomment-340009897>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AfUS57kfe3sc4lKy7iHMGvI68n2kRG7aks5swfuIgaJpZM4QIlEl>
> .
>

@rlaverde, this error has been reported several times, so we should catch `IOError` (so things work in Python 2 and 3) and see what action to take in that case (I'm not so sure what to do...).

Resolving patch:
diff --git a/spyder_profiler/widgets/profilergui.py b/spyder_profiler/widgets/profilergui.py
--- a/spyder_profiler/widgets/profilergui.py
+++ b/spyder_profiler/widgets/profilergui.py
@@ -30,7 +30,7 @@
                             QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget)
 
 # Local imports
-from spyder.config.base import get_conf_path, get_translation
+from spyder.config.base import get_conf_path, get_translation, debug_print
 from spyder.py3compat import to_text_string
 from spyder.utils import icon_manager as ima
 from spyder.utils.qthelpers import (create_toolbutton, get_item_user_text,
@@ -462,7 +462,14 @@ def load_data(self, profdatafile):
         self.profdata = stats_indi[0]
         
         if self.compare_file is not None:
-            stats_indi.append(pstats.Stats(self.compare_file))
+            try:
+                stats_indi.append(pstats.Stats(self.compare_file))
+            except IOError as e:
+                QMessageBox.critical(
+                    self, _("Error"),
+                    _("Error when trying to load profiler results"))
+                debug_print("Error when calling pstats, {}".format(e))
+                self.compare_file = None
         map(lambda x: x.calc_callees(), stats_indi)
         self.profdata.calc_callees()
         self.stats1 = stats_indi


Test patch: