Conda envs are not activated in IPython console (Big Sur issue?)
See original GitHub issueIssue Report Checklist
-
Searched the issues page for similar reports
-
Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
-
Reproduced the issue after updating with
conda update spyder
(orpip
, if not using Anaconda) -
Could not reproduce inside
jupyter qtconsole
(if console-related) -
Tried basic troubleshooting (if a bug/error)
- Restarted Spyder
- Reset preferences with
spyder --reset
- Reinstalled the latest version of Anaconda
- Tried the other applicable steps from the Troubleshooting Guide
-
Completed the Problem Description, Steps to Reproduce and Version sections below
Problem Description
Setting the Python interpreter in settings to an interpreter in a conda environment, does not make the libraries of that conda environment available.
What steps reproduce the problem?
- Create a conda environment for spyder:
conda create --name spyder python=3.8 spyder
- Create a conda environment for a project holding different libraries (this example uses 1 library):
conda create --name some_project python=3.8 pandas spyder-kernels
- Start spyder:
conda activate spyder; spyder
- Go the Spyder preferences (<kbd>CMD</kbd> + <kbd>,</kbd>) and set the Python interpreter to:
/path/to/anaconda3/envs/some_project/bin/python
- Start a new console in Spyder, this one uses the interpreter set in the previous step.
- Try to load pandas by typing the following command in the console:
import pandas
What is the expected output? What do you see instead?
As I installed pandas in the some_project
conda environment, which supplies the Python interpreter according to Spyders settings, I expect that the pandas library is imported.
Instead, I get the following error:
File "<ipython-input-1-38d4b0363d82>", line 1, in <module>
import pandas
ModuleNotFoundError: No module named 'pandas'
This indicates that the interpeter being used is not the one in the some_project
environment.
I double checked that I can use pandas in some_project
, this worked as expected: conda activate some_project; python -c "import pandas"
Paste Traceback/Error Below (if applicable)
>>> Traceback (most recent call last):
File "/Users/ba/opt/anaconda3/envs/spyder/lib/python3.8/site-packages/spyder/plugins/editor/widgets/status.py", line 113, in process_git_data
branches, branch, files_modified = output
TypeError: cannot unpack non-iterable NoneType object
Versions
- Spyder version: 4.2.1 None
- Python version: 3.8.6 64-bit
- Qt version: 5.12.9
- PyQt5 version: 5.12.3
- Operating System: Darwin 20.2.0
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 : 1.6.0 (OK)
diff_match_patch >=20181111 : 20200713 (OK)
intervaltree >=3.0.2 : 3.0.2 (OK)
IPython >=7.6.0 : 7.19.0 (OK)
jedi =0.17.2 : 0.17.2 (OK)
jsonschema >=3.2.0 : 3.2.0 (OK)
keyring >=17.0.0 : 21.5.0 (OK)
nbconvert >=4.0 : 6.0.7 (OK)
numpydoc >=0.6.0 : 1.1.0 (OK)
parso =0.7.0 : 0.7.0 (OK)
pexpect >=4.4.0 : 4.8.0 (OK)
pickleshare >=0.4 : 0.7.5 (OK)
psutil >=5.3 : 5.8.0 (OK)
pygments >=2.0 : 2.7.3 (OK)
pylint >=1.0 : 2.6.0 (OK)
pyls >=0.36.2;<1.0.0 : 0.36.2 (OK)
pyls_black >=0.4.6 : 0.4.6 (OK)
pyls_spyder >=0.3.0 : 0.3.0 (OK)
qdarkstyle >=2.8 : 2.8.1 (OK)
qtawesome >=0.5.7 : 1.0.2 (OK)
qtconsole >=5.0.1 : 5.0.1 (OK)
qtpy >=1.5.0 : 1.9.0 (OK)
rtree >=0.8.3 : 0.9.5 (OK)
setuptools >=39.0.0 : 49.6.0.post20201009 (OK)
sphinx >=0.6.6 : 3.4.0 (OK)
spyder_kernels >=1.10.1;<1.11.0 : 1.10.1 (OK)
textdistance >=4.2.0 : 4.2.0 (OK)
three_merge >=0.1.1 : 0.1.1 (OK)
watchdog >=0.10.3 : 1.0.2 (OK)
zmq >=17 : 20.0.0 (OK)
# Optional:
cython >=0.21 : None (NOK)
matplotlib >=2.0.0 : None (NOK)
numpy >=1.7 : None (NOK)
pandas >=1.1.1 : None (NOK)
scipy >=0.17.0 : None (NOK)
sympy >=0.7.3 : None (NOK)
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (11 by maintainers)
Top GitHub Comments
The fix turned out to be pretty simple (see PR #14565). Given its importance, I plan to include it in a new build for 4.2.1 (see https://github.com/conda-forge/spyder-feedstock/pull/93).
Hey @b-a0, thanks for reporting. You said:
From this step you’re missing to install
spyder-kernels
, i.e. you need to run:conda create --name some_project python=3.8 pandas spyder-kernels
. That’s because Spyder can only connect to environments that havespyder-kernels
in them.I don’t understand how this step could have worked if you didn’t install
spyder-kernels
in step 2. Spyder shows an error message and don’t start a console whenspyder-kernels
is missing.Yeah, it seems Spyder is trying to import Pandas from the interpreter where it was installed (i.e. the one in your
spyder
conda env).Please run the following commands in the IPython console to know what interpreter you’re really using: