spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.34k stars 1.62k forks source link

Spyder 4 launching from anaconda prompt but not from shortcut nor .exe #13250

Closed DiegoF90 closed 4 years ago

DiegoF90 commented 4 years ago

Problem Description

I have a just installed fresh version of spyder in a local anaconda env using:

conda create -n my_env python=3 spyder=4

Starting spyder from the prompt (after activate my_env) works fine and starts Spyder4.

However, when opening using the shortcut Spyder does not open. To figure out what was happening I manually ran:

C:\Users\MyUser\AppData\Local\conda\conda\envs\gmv\pythonw.exe C:\ProgramData\Anaconda3\cwp.py C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env "C:/Users/MyUser/AppData/Local/conda/conda/envs/my_env /pythonw.exe" "C:/Users/MyUser/AppData/Local/conda/conda/envs/my_env /Scripts/spyder-script.py"

which does not do anything. To recover an error message I thought of using python.exe instead of pythonw.exe. This gave:


Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\cwp.py", line 9, in <module>
    from menuinst.knownfolders import FOLDERID, get_folder_path, PathNotFoundException
ModuleNotFoundError: No module named 'menuinst'

So I installed "menuinst" using conda install menuinst. After re-running I got:

menuinst called from non-root env C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env

I do not know what to do at that point.

I also tried running from spyder.exe but get:


Traceback (most recent call last):
  File "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\Scripts\spyder-script.py", line 6, in <module>
    from spyder.app.start import main
  File "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\lib\site-packages\spyder\app\start.py", line 22, in <module>
    import zmq
  File "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\lib\site-packages\zmq\__init__.py", line 47, in <module>
    from zmq import backend
  File "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.

I tried "upgrading" zmq" but there is no such package.

Furthermore I tried running "spyder3.exe" but again got an error message saying:

Unable to create process using '"c:\ci\spyder_1589206422876_h_env\pythonw.exe" "C:\Users\MyUser\AppData\Local\conda\conda\envs\my_env\Scripts\spyder.exe" ': The system cannot find the file specified

I do not know what else to do to spot the bug but I think it is an issue with the latest Spyder 4 install?

What steps reproduce the problem?

  1. Create a new environment with python 3 and spyder 4
  2. Launch spyder using the .exe or by clicking the created shortcut lnk
  3. Spyder does not open

Versions

``` alabaster 0.7.12 py_0 argh 0.26.2 py38_0 astroid 2.4.2 py38_0 atomicwrites 1.4.0 py_0 attrs 19.3.0 py_0 autopep8 1.5.3 py_0 babel 2.8.0 py_0 backcall 0.2.0 py_0 bcrypt 3.1.7 py38he774522_1 bleach 3.1.5 py_0 brotlipy 0.7.0 py38he774522_1000 ca-certificates 2020.1.1 0 certifi 2020.6.20 py38_0 cffi 1.14.0 py38h7a1dbc1_0 chardet 3.0.4 py38_1003 cloudpickle 1.4.1 py_0 colorama 0.4.3 py_0 cryptography 2.9.2 py38h7a1dbc1_0 decorator 4.4.2 py_0 defusedxml 0.6.0 py_0 diff-match-patch 20181111 py_0 docutils 0.16 py38_1 entrypoints 0.3 py38_0 flake8 3.8.3 py_0 future 0.18.2 py38_1 icu 58.2 vc14hc45fdbb_0 [vc14] idna 2.9 py_1 imagesize 1.2.0 py_0 importlib-metadata 1.6.1 py38_0 importlib_metadata 1.6.1 0 intervaltree 3.0.2 py_0 ipykernel 5.3.0 py38h5ca1d4c_0 ipython 7.15.0 py38_0 ipython_genutils 0.2.0 py38_0 isort 4.3.21 py38_0 jedi 0.15.2 py38_0 jinja2 2.11.2 py_0 jpeg 9b vc14h4d7706e_1 [vc14] jsonschema 3.2.0 py38_0 jupyter_client 6.1.3 py_0 jupyter_core 4.6.3 py38_0 keyring 21.1.1 py38_2 lazy-object-proxy 1.4.3 py38he774522_0 libpng 1.6.37 h2a8f88b_0 libsodium 1.0.16 h9d3ae62_0 libspatialindex 1.9.3 h33f27b4_0 markupsafe 1.1.1 py38he774522_0 mccabe 0.6.1 py38_1 mistune 0.8.4 py38he774522_1000 nbconvert 5.6.1 py38_0 nbformat 5.0.7 py_0 numpydoc 1.0.0 py_0 openssl 1.1.1g he774522_0 packaging 20.4 py_0 pandoc 2.2.3.2 0 pandocfilters 1.4.2 py38_1 paramiko 2.7.1 py_0 parso 0.5.2 py_0 pathtools 0.1.2 py_1 pexpect 4.8.0 py38_0 pickleshare 0.7.5 py38_1000 pip 20.1.1 py38_1 pluggy 0.13.1 py38_0 prompt-toolkit 3.0.5 py_0 psutil 5.7.0 py38he774522_0 pycodestyle 2.6.0 py_0 pycparser 2.20 py_0 pydocstyle 5.0.2 py_0 pyflakes 2.2.0 py_0 pygments 2.6.1 py_0 pylint 2.5.3 py38_0 pynacl 1.3.0 py38h62dcd97_0 pyopenssl 19.1.0 py38_0 pyparsing 2.4.7 py_0 pyqt 5.9.2 py38ha925a31_4 pyrsistent 0.16.0 py38he774522_0 pysocks 1.7.1 py38_0 python 3.8.3 he1778fa_0 python-dateutil 2.8.1 py_0 python-jsonrpc-server 0.3.4 py_0 python-language-server 0.31.9 py38_0 pytz 2020.1 py_0 pywin32 227 py38he774522_1 pywin32-ctypes 0.2.0 py38_1000 pyyaml 5.3.1 py38he774522_0 pyzmq 18.1.1 py38ha925a31_0 qdarkstyle 2.8.1 py_0 qt 5.9.7 vc14h73c81de_0 [vc14] qtawesome 0.7.2 py_0 qtconsole 4.7.5 py_0 qtpy 1.9.0 py_0 requests 2.24.0 py_0 rope 0.17.0 py_0 rtree 0.9.4 py38h21ff451_1 setuptools 47.3.1 py38_0 sip 4.19.22 py38ha925a31_0 six 1.15.0 py_0 snowballstemmer 2.0.0 py_0 sortedcontainers 2.2.2 py_0 sphinx 3.1.1 py_0 sphinxcontrib-applehelp 1.0.2 py_0 sphinxcontrib-devhelp 1.0.2 py_0 sphinxcontrib-htmlhelp 1.0.3 py_0 sphinxcontrib-jsmath 1.0.1 py_0 sphinxcontrib-qthelp 1.0.3 py_0 sphinxcontrib-serializinghtml 1.1.4 py_0 spyder 4.1.3 py38_0 spyder-kernels 1.9.1 py38_0 sqlite 3.32.3 h2a8f88b_0 testpath 0.4.4 py_0 toml 0.10.0 pyh91ea838_0 tornado 6.0.4 py38he774522_1 traitlets 4.3.3 py38_0 ujson 1.35 py38he774522_0 urllib3 1.25.9 py_0 vc 14.1 h21ff451_4 vs2015_runtime 14.16.27012 hf0eaf9b_2 watchdog 0.10.2 py38_0 wcwidth 0.2.4 py_0 webencodings 0.5.1 py38_1 wheel 0.34.2 py38_0 win_inet_pton 1.1.0 py38_0 wincertstore 0.2 py38_0 wrapt 1.11.2 py38he774522_0 yaml 0.1.7 vc14hb31d195_1 [vc14] yapf 0.29.0 py_0 zeromq 4.3.1 h33f27b4_3 zipp 3.1.0 py_0 zlib 1.2.11 vc14h1cdd9ab_1 [vc14] ```
juanis2112 commented 4 years ago

@CAM-Gerlach can you take a look at this?

CAM-Gerlach commented 4 years ago

Hey, not sure what's going on; running Spyder on Windows myself I haven't run into this specific issue. Just to confirm, have you ever used pip to install Python packages on this machine? Just in case, you'll want to complete Part 1, Step 3 of our tutorial video on troubleshooting issues with Spyder, Pip and Conda. You can also try running the following commands in your Anaconda Prompt in the base environment to ensure everythiing is up to date:

conda update conda
conda update anaconda

Then, if it still doesn't work, force-reinstall menuinst in base:

conda install --force menuinst

and then force reinstall spyder in your environment:

conda activate my_env
conda install --force spyder

If that doesn't work; I'm not sure what is going on...sometimes installing the shortcut fails randomly on the Anaconda side. Its possible this may be due to a permissions issue, e.g. installing Anaconda for all users and running as a non-admin, for example, or something else machine-specific. If that's the case, all I can recommend is doing a clean uninstall and reinstalling Anaconda, preferably with a different install type than before,

The other suggestions in our Spyder Troubleshooting Guide, specifically the Basic First Aid and Emergency CPR sections, may also be of help, if you haven't already tried them.

Let us know how it goes, and best of luck!

DiegoF90 commented 4 years ago

Hi @CAM-Gerlach, No I have not used pip. This is a new fresh installation. I have also forced install spyder and menuinst with no change. Is there anything else I should try? Any additional information I can provide you so that you can replicate?

CAM-Gerlach commented 4 years ago

Hey, really sorry for the trouble. Once I fixed the formatting of your environment list (which I should have done before, sorry), I noticed that like prompt_toolkit in your previous issue #13228 , importlib-metadata is included twice (once with dash and once with underscore, and with the same version but different build codes), though I'm not sure if that is actually an issue given one of my Spyder envs on Windows also has two copies of the same but I'm unable to reproduce the issue.

Is there anything else I should try?

There are some more things you could try from our Troubleshooting Guide, given the information we have. Specifically, I suggest step 7 under Basic First Aid, clean-uninstalling and reinstalling Anaconda, and then if problems persist, completing steps 4-8 under Emergency CPR.

As I describe under step 3 of Emergency CPR, typically one method of launching Spyder working (e.g. command line) but not another (shortcut) is almost certainly indicative of a problem with your Anaconda install, not anything that Spyder has any control over. To resolve the issues uses have been experiencing with Anaconda lately, we are in the final stages of building standalone installers for Spyder that will avoid almost all of these issues and make it easier to install, launch and update Spyder on all the platforms we support, as well as for us to fix problems when they do occur.

With the information I have available, assuming you have just completed a clean reinstall of Anaconda itself, I either suspect something went wrong with your Anaconda install somehow, some sort of security software is interfering with either the install or the launch. Otherwise, if you are using the same install as in #13228 (which was well over 3 years out of date), I would suspect either a pip, conda-forge or botched default package installation upgrade somewhere, or simply the age of the environment and/or the huge stretch upgrading exposed an issue.

Any additional information I can provide you so that you can replicate?

You've provided a lot of useful information already, though as the problem is apparently outside our direct control and something specific to your environment, it doesn't look like we can actually repro it. Could you let us know your Windows version, if your Anaconda install was the same one from #13228 , describe how you have your conda environments set up and any other troubleshooting steps you tried? Also, have you ever had any Python installs on this machine, check if there is anything in the %appdata%/Python directory (if it exists), check your PATH for any other Python entries and provide us the output of your PYTHONPATH environment variable (if it exists)? Thanks!

DiegoF90 commented 4 years ago

Hi @CAM-Gerlach,

Thanks for your help. No this is not the same install as that of #13228 this is a new fresh install in a different PC. The env was set up simply by running the code posted above: conda create -n my_env python=3 spyder=4 I am using Windows 10, I also tried all the above steps you suggest. There is another python install (3.6) which is the one the base Anaconda installation comes with. There are no other Python entries in my PATH and my PYTHONPATH only contains references to the internal library (which does not contain any python or spyder versions).

I believe, as you suggest, that it is some security software as I am not using admin rights. This is sadly not an option here as those systems are used inside an organization. I actually believe that this is the case for many of the users, more so with the current trend of python becoming a must have language at several banks and startups. It would be great if you manage to replicate this by building the installation by not using admin rights? also, it would be very helpful if when building future releases of Spyder there is a small portion dedicated to making sure it works for non admin users.

Feel free to close the issue if you like :)

CAM-Gerlach commented 4 years ago

Hey, thanks for your detailed followup, and for your patience. It has essentially ruled out the great majority of potential issues with your environment; aside from something esoteric, the remaining likely possibilities are some unpredictable failure when installing Anaconda, or security software on your machine interfering with the install, shortcut or startup process. Does the same behavior occur when Spyder is launched via the shortcut from the default base environment, or just the shortcut for the copy of Spyder installed in my_env? What is the output when menuinst runs after installing or updating Spyder?

In any case, until our standalone installers are out soon, my best advice would again be to do a clean uninstall and reinstall of Anaconda, and if problems persist, report it to them. It is conda and menuinst that installs the shortcut, not our code, so we have very limited control over that process. Do other shortcuts work (like Jupyter) in the same env? Our standalone installers should not experience the same issue, and if they do we'll be able to swiftly fix it for you (unless it has to do with interference by some security software that we don't have control over).

As for the issue of admin rights, Anaconda by default is installed "Just for me" (i.e. per-user, without admin), and that's typically how most of our users (including myself) have successfully used it across a variety of both personal and institutional machines. In the past, there have occasionally been problems reported related to this, but they usually have to do with Anaconda installed as admin, and then being used from a different, non-admin user account. Back when that was more frequently reported, I actually spend several days and a number of attempts to reproduce those errors myself on a clean Win 10 test box but was never able to, and I don't think we've seen this problems reported lately, so I'm not sure that's what's going on here.

What I think may be more likely is some sort of security software interfering, and that's unfortunately not anything we have direct control over from the Spyder side; it most has a very high degree of machine to machine variation that we cannot account for, and usually operates at a much higher privilege level than us such that the only real solution is to ensure your IT folks perform the appropriate whitelisting such that your software functions as you need it to.

CAM-Gerlach commented 4 years ago

Hey @DiegoF90 , did you manage to resolve your problem? Just checking in, thanks!

DiegoF90 commented 4 years ago

Hi @CAM-Gerlach, many thanks for your support and not giving up on the issue. I actually did not manage to make it work but just decided to build my own shortcut as a workaround. For completeness to address your questions above:

My case is def the one you mentioned, i.e. Anaconda installed in admin and individual user using it. Also, digging a bit more I found that I was also having this issue when installing Spyder using my anaconda version, which might be related. I believe the issue was fixed in a later version of menuinst, but I cannot update the menuinst in my root (to make an installation of spyder using an updated version).

Hopefully it will come the time Spyder is whitelisted by default in most companies. Looking forward to the standalone installers. Cheers!

CAM-Gerlach commented 4 years ago

just decided to build my own shortcut as a workaround.

That was actually what I was about to suggest, if all else failed, since given your technical skill level I figured it would be a pretty easy task for you even without my help.

The output of menuinst after installing and updating is the same as above

Its possible that a later version of conda/menuinst/etc fixes this, if you can get it updated; I know there have been some improvements on this in the past couple years. Not sure how old your environment is.

I am afraid I have never used Jupyter,

Me neither, I was just curious if menuinst was acting up with other application in the env, or just Spyder. But it seems like the former.

Hopefully it will come the time Spyder is whitelisted by default in most companies. Looking forward to the standalone installers. Cheers!

It was at the one I worked at, fortunately. Otherwise, there are two ways to fix this long-term. You could install Anaconda (or the much lighter weight Miniconda) "Just for me" rather than using the system install (which you can do without admin and alongside your existing system Anaconda install, so long as your system doesn't have restrictive security policies. In fact, you can install Spyder in your per-user install and use it with your existing environments in your system install, just as easily as using it between environments in the same install. Alternatively, you can wait for our own installers, which install Spyder as a standalone application and can be done either per-user or system-wide (admin), and will again work with your existing Anaconda envs.

In any case, thanks for your help on this, best of luck and happy Spydering!