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.

Why is Spyder using libraries from base environment instead of virtual environment

See original GitHub issue

I created and activated a virtual environment with virtualenv:

virtualenv venv
source venv/bin/activate

Then I installed spyder kernels and other libraries in the virtual environment:

pip install spyder-kernels==0.*
pip install numba==0.50

Then I launched Spyder in the virtual environment:

spyder

And I changed the python interpreter in Spyder to the correct path using: > Python > Preferences > Python interpreter > Use the following Python interpreter

My Python interpreter in my virtual environment is

/Users/myname/venv/bin/python

However, when I import libraries in Spyder, rather than the libraries installed in the virtual environment, Spyder uses the libraries from the base Anaconda environment.

import numba
print(numba.__version__)
0.38.0
print(numba.__file__)
/anaconda3/lib/python3.6/site-packages/numba/__init__.py

This is causing all kinds of errors in my code. What can I do to force Spyder to only use libraries installed in my virtual environment?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jafetgadocommented, Jul 3, 2020

I upgraded Anaconda Navigator to the most recent version, which came with Spyder 4.0.1 and Python 3.7.6. That alone solved the problem for me. Thank you.

1reaction
ccordoba12commented, Jul 3, 2020

That’s very old. Please update at least to 3.3.6 and try again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is Spyder using libraries from base environment instead ...
However, when I import libraries in Spyder, rather than the libraries installed in the virtual environment, Spyder uses the libraries from ...
Read more >
Frequently Asked Questions — Spyder 5 documentation
Q: How do I run Spyder installed in a conda environment using Anaconda Navigator?
Read more >
Working with packages and environments in Spyder - GitHub
The most common problem: Using newly-installed packages inside Spyder ... This happens because foo was installed (with either conda or pip ) in...
Read more >
5 Steps : Setup Python Virtual environment in Spyder IDE
5 Steps : Setup Python Virtual environment in Spyder IDE · 1. Installing virtualenv package with pip · 2. Creating Virtual Environment for...
Read more >
Easy Way to switch Environments in Spyder? - Google Groups
Install Spyder in an environment created by pip and activated using source command rather than command. The reason being when you switch conda...
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