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.

Conda envs are not activated in IPython console (Big Sur issue?)

See original GitHub issue

Issue 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 (or pip, 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?

  1. Create a conda environment for spyder: conda create --name spyder python=3.8 spyder
  2. 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
  3. Start spyder: conda activate spyder; spyder
  4. Go the Spyder preferences (<kbd>CMD</kbd> + <kbd>,</kbd>) and set the Python interpreter to: /path/to/anaconda3/envs/some_project/bin/python
  5. Start a new console in Spyder, this one uses the interpreter set in the previous step.
  6. 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:closed
  • Created 3 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, Jan 10, 2021

I don’t think the solution is simple, so it won’t be possible to patch 4.2.1 with it

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).

1reaction
ccordoba12commented, Dec 22, 2020

Hey @b-a0, thanks for reporting. You said:

  1. Create a conda environment for a project holding different libraries

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 have spyder-kernels in them.

  1. Start a new console in Spyder, this one uses the interpreter set in the previous step.

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 when spyder-kernels is missing.

This indicates that the interpeter being used is not the one in the some_project environment.

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:

import sys
sys.executable
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spyder 5.1.5 does not activate environment properly, leads to ...
I just installed Spyder 5.1.5 using the standalone installer. I connected it to my existing conda environment (located in an unusual ...
Read more >
Install Python packages to a specific Conda environment - AWS
To install the Python packages in the correct Conda environment, first activate the environment before running pip install or conda install ...
Read more >
I can't install TensorFlow-macos a… | Apple Developer Forums
I got this error with (tensorflow-metal) virtualenv on Big Sur with an AMD ... Ummm, it just not working properly, seems like it...
Read more >
Frequently Asked Questions — Spyder 5 documentation
Q: How do I run Spyder installed in a conda environment using Anaconda Navigator? Select the environment you want to launch Spyder from...
Read more >
Napari issue with qt library - Usage & Issues - Image.sc Forum
I have tried to install napari in different ways (in a new conda env each time), as was suggested here: Napari issues on...
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