Repository: spyder-ide/spyder

Issue:
OSError when importing Numpy in Object Explorer 
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [x] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [x] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [ ] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [ ] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [x] Tried basic troubleshooting (if a bug/error)
    * [x] Restarted Spyder
    * [x] Reset preferences with ``spyder --reset``
    * [ ] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [ ] Tried the other applicable steps from the Troubleshooting Guide
* [x] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below


## Problem Description

Spyder is not launching in my laptop. Its giving traceback call. I have tried to update conda from anaconda prompt shell but its still not working.

### What steps reproduce the problem?

1. I launch Anaconda navigator.
2.  From there I launched spyder.
3. Thats where it caused problem.

### What is the expected output? What do you see instead?

I see a traceback call

### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

Traceback (most recent call last):
File "C:\Users\Pranjal\anaconda3\Scripts\spyder-script.py", line 10, in 
sys.exit(main())
File "C:\Users\Pranjal\anaconda3\lib\site-packages\spyder\app\start.py", line 201, in main
from spyder.app import mainwindow
File "C:\Users\Pranjal\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 167, in 
from spyder.utils.environ import WinUserEnvDialog
File "C:\Users\Pranjal\anaconda3\lib\site-packages\spyder\utils\environ.py", line 19, in 
from spyder.plugins.variableexplorer.widgets.collectionseditor import (
File "C:\Users\Pranjal\anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionseditor.py", line 57, in 
from spyder.plugins.variableexplorer.widgets.collectionsdelegate import (
File "C:\Users\Pranjal\anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\collectionsdelegate.py", line 31, in 
from spyder.plugins.variableexplorer.widgets.objectexplorer.attribute_model \
File "C:\Users\Pranjal\anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\objectexplorer\__init__.py", line 19, in 
from .attribute_model import DEFAULT_ATTR_COLS, DEFAULT_ATTR_DETAILS
File "C:\Users\Pranjal\anaconda3\lib\site-packages\spyder\plugins\variableexplorer\widgets\objectexplorer\attribute_model.py", line 29, in 
import numpy as np
File "C:\Users\Pranjal\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 142, in 
from . import core
File "C:\Users\Pranjal\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 23, in 
WinDLL(os.path.abspath(filename))
File "C:\Users\Pranjal\anaconda3\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application


```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 4.0.1
* Python version: 3.7.6
* Qt version: 5.9.7
* PyQt version: 5.9.2
* Operating System name/version: Windows 10 Home

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
PASTE DEPENDENCIES HERE
```



Discussion:
Please remove this directory

    C:\Users\Pranjal\AppData\Roaming\Python

Also, please **do not** use pip to install packages that can be installed by conda in the future. This error was caused because you installed Numpy with pip.
@steff456, please take a look at this one. The idea is very simple: please change the `ImportError` below by an `Exception` to catch any kind of error when importing Numpy at that point:

https://github.com/spyder-ide/spyder/blob/3433a2d26990ae531095b6192591725aec077d1d/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py#L28-L33

Resolving patch:
diff --git a/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py b/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py
--- a/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py
+++ b/spyder/plugins/variableexplorer/widgets/objectexplorer/attribute_model.py
@@ -27,7 +27,7 @@
 # Attribute models constants
 try:
     import numpy as np
-except ImportError:
+except Exception:
     _NUMPY_INSTALLED = False
 else:
     _NUMPY_INSTALLED = True


Test patch: