question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python interpreter path overwritten in console w/external interpreter on the MacOS standalone version if the `Spyder.app` name is changed

See original GitHub issue

Issue Report Checklist

  • Searched the issues page for similar reports
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset

Problem Description

I am using Spyder 5.3.0, installed in mac from the distributed .dmg, but need to use an external Python interpreter to debug with packages not present in the “spyder” Python. When the external Python is started, the path has been reset to that of the Python interpreter running Spyder.

What steps reproduce the problem?

  1. Change interpreter setting for Python interpreter
  2. restart console
  3. display sys.path

What is the expected output? What do you see instead?

Python should run normally and packages should load properly. But, this does not happen.

Paste Traceback/Error Below (if applicable)

Output in console

Python 3.9.12 (main, Apr  5 2022, 01:53:17)
Type "copyright", "credits" or "license" for more information.

IPython 7.31.1 -- An enhanced Interactive Python.

Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
  File "site.pyc", line 32, in <module>
  File "site.pyc", line 29, in _import_os
  File "os.pyc", line 29, in <module>
  File "_collections_abc.pyc", line 416, in <module>
TypeError: type 'types.GenericAlias' is not an acceptable base type
0.00s - Debugger warning: The os.path.realpath.__code__.co_filename (posixpath.pyc)
0.00s - is not absolute, which may make the debugger miss breakpoints.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

In[1]: import sys

In[2]: sys.executable
Out[2]: '/Users/toby/conda39/envs/spyder530/bin/python'

In[3]: sys.path
Out[3]: 
['/Users/toby/Applications/Spyder530.app/Contents/Resources',
 '/Users/toby/Applications/Spyder530.app/Contents/Resources/lib/python39.zip',
 '/Users/toby/Applications/Spyder530.app/Contents/Resources/lib/python3.9',
 '/Users/toby/Applications/Spyder530.app/Contents/Resources/lib/python3.9/lib-dynload',
 '/Users/toby/Applications/Spyder530.app/Contents/Resources/lib/python3.9/site-packages.zip',
 '',
 '/Users/toby/Applications/Spyder530.app/Contents/Resources/lib/python3.9/site-packages',
 '/Users/toby/Applications/Spyder530.app/Contents/Resources/lib/python3.9/IPython/extensions',
 '/Users/toby/Applications/Spyder501.app/Contents/Resources/sn_0_22672798',
 '/Users/toby/.ipython']

Note that the Python image I am running is in ~/conda39/envs/spyder530/bin but the path is referencing locations in ~/Applications/Spyder530.app, where the latter is where Spyder is installed.

When ~/conda39/envs/spyder530/bin/python is run directly:

(spyder530) conda39 dev % /Users/toby/conda39/envs/spyder530/bin/python 
Python 3.9.12 (main, Apr  5 2022, 01:53:17) 
[Clang 12.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/Users/toby/conda39/envs/spyder530/lib/python39.zip', 
'/Users/toby/conda39/envs/spyder530/lib/python3.9', 
'/Users/toby/conda39/envs/spyder530/lib/python3.9/lib-dynload', 
'/Users/toby/conda39/envs/spyder530/lib/python3.9/site-packages']
>>> 

Versions

  • Spyder version: 5.3.0
  • Python version: 3.9.5
  • Qt version: 5.15.2
  • PyQt version: 5.15.6
  • Operating System name/version: MacOS 10.15.7

Dependencies

# Mandatory:
applaunchservices >=0.1.7            :  0.2.1 (OK)
atomicwrites >=1.2.0                 :  1.4.0 (OK)
chardet >=2.0.0                      :  4.0.0 (OK)
cloudpickle >=0.5.0                  :  2.0.0 (OK)
cookiecutter >=1.6.0                 :  1.7.3 (OK)
diff_match_patch >=20181111          :  20200713 (OK)
intervaltree >=3.0.2                 :  3.1.0 (OK)
IPython >=7.31.1;<8.0.0              :  7.32.0 (OK)
jedi >=0.17.2;<0.19.0                :  0.18.1 (OK)
jellyfish >=0.7                      :  0.9.0 (OK)
jsonschema >=3.2.0                   :  4.4.0 (OK)
keyring >=17.0.0                     :  23.5.0 (OK)
nbconvert >=4.0                      :  6.4.5 (OK)
numpydoc >=0.6.0                     :  1.2.1 (OK)
parso >=0.7.0;<0.9.0                 :  0.8.3 (OK)
pexpect >=4.4.0                      :  4.8.0 (OK)
pickleshare >=0.4                    :  0.7.5 (OK)
psutil >=5.3                         :  5.9.0 (OK)
pygments >=2.0                       :  2.11.2 (OK)
pylint >=2.5.0                       :  2.13.3 (OK)
pyls_spyder >=0.4.0                  :  0.4.0 (OK)
pylsp >=1.4.1;<1.5.0                 :  1.4.1 (OK)
pylsp_black >=1.2.0                  :  1.2.0 (OK)
qdarkstyle >=3.0.2;<3.1.0            :  3.0.3 (OK)
qstylizer >=0.1.10                   :  0.2.1 (OK)
qtawesome >=1.0.2                    :  1.1.1 (OK)
qtconsole >=5.3.0;<5.4.0             :  5.3.0 (OK)
qtpy >=2.0.1                         :  2.0.1 (OK)
rtree >=0.9.7                        :  0.9.7 (OK)
setuptools >=49.6.0                  :  60.10.0 (OK)
sphinx >=0.6.6                       :  4.5.0 (OK)
spyder_kernels >=2.3.0;<2.4.0        :  2.3.0 (OK)
textdistance >=4.2.0                 :  4.2.2 (OK)
three_merge >=0.1.1                  :  0.1.1 (OK)
watchdog >=0.10.3                    :  2.1.7 (OK)
zmq >=17                             :  22.3.0 (OK)

# Optional:
cython >=0.21                        :  0.29.28 (OK)
matplotlib >=3.0.0                   :  3.5.1 (OK)
numpy >=1.7                          :  1.22.3 (OK)
pandas >=1.1.1                       :  1.4.1 (OK)
scipy >=0.17.0                       :  1.8.0 (OK)
sympy >=0.7.3                        :  1.10.1 (OK)

# Spyder plugins:
spyder_terminal.terminalplugin 1.2.2 :  1.2.2 (OK)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
briantobycommented, May 12, 2022

@mrclary is completely correct! Changing the app name back to spyder.app fixes this. If Spyder can’t be made robust against silly users renaming it, perhaps a warning can be added.

Thanks for the quick fix!

1reaction
mrclarycommented, May 12, 2022

I’d like to keep the issue open at least util I can investigate robustifying Spyder

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to change python version in anaconda spyder
keyboard shortcut Ctrl + Alt + Shift + P; Tools -> Preferences. And depending on the Spyder version you can change the interpreter...
Read more >
Common Illnesses — Spyder 5 documentation
If you receive the message An error occurred while starting the kernel in the IPython Console, Spyder was unable to launch a new...
Read more >
Documentation: MultiQC
This is the easiest way to install MultiQC. pip is the package manager for the Python Package Manager. It comes bundled with recent...
Read more >
PySimpleGUI
PySimpleGUI User's Manual. Python GUI For Humans - Transforms tkinter, Qt, Remi, WxPython into portable people-friendly Pythonic interfaces. The Call Reference ...
Read more >
Databricks Connect | Databricks on AWS
Run large-scale Spark jobs from any Python, Java, Scala, or R application. Anywhere you can import pyspark , import org.apache.spark , or require( ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found