What steps will reproduce the problem?
What is the expected output? What do you see instead?
I want wo use this environment (send the code to the interpreter)
The interpreter breaks down.
Isn't there a way to switch different Anaconda envs within Spyder?
Please provide any additional information below
Please go to the menu entry Help > Optional Dependencies
(or
Help > Dependencies
), press the button Copy to clipboard
and paste the contents below:
The interpreter breaks down.
Could you be more specific?
Spyder is not limited to use in an Anaconda distribution. I also use Spyder in a WinPython distribution. I don't think it is practical for Spyder to know which package manager installed it and handle all the complexities of changing environments.
With both Anaconda and WinPython, I create a separate Windows batch file for each environment to run Spyder. Discussion and example batch files are at https://github.com/winpython/winpython/issues/351
I still don't understand that well how you guys are talking about, but our plan to manage environments/virtualenvs in Spyder is by adding the possibility of a setting a particular Python interpreter per project.
That will be done in Spyder 3.3.
The interpreter breaks down.
Could you be more specific?
I go to "Preferences > Python interpreter > Use the following interpreter" and change it to the newly created environment:
/home/cord/.anaconda3/envs/test/bin/python3
Now I restart Spyder and get the error:
An error ocurred while starting the kernel
Your Python environment or installation doesn't have the ipykernel module installed on it. Without this module is not possible for Spyder to create a console for you.
You can install ipykernel by running in a terminal:
pip install ipykernel
So I install ipykernel
with pip within the environment:
(test) cord@cord-Laptop:~/.anaconda3/bin$ pip install ipykernel
Successfully installed decorator-4.0.11 ipykernel-4.5.2 ipython-5.3.0 ipython-genutils-0.1.0 jupyter-client-5.0.0 jupyter-core-4.3.0 pexpect-4.2.1 pickleshare-0.7.4 prompt-toolkit-1.0.13 ptyprocess-0.5.1 pygments-2.2.0 pyzmq-16.0.2 simplegeneric-0.8.1 tornado-4.4.2 traitlets-4.3.2 wcwidth-0.1.7
(test) cord@cord-Laptop:~/.anaconda3/bin$
And if I open Spyder it still shows the anaconda default environment:
Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06)
Would this generally be the right way to work with different environments?
Or is this the case because Spyder is started from another anaconda environment and I normally had to start it from the system python interpreter?
And if I open Spyder it still shows the anaconda default environment
Are you sure is that the default environment? Please try to import any package besides ipykernel
to see if that's true or not.
And if I open Spyder it still shows the anaconda default environment
Are you sure is that the default environment? Please try to import any package besides ipykernel to see if that's true or not.
You are right, it somehow worked after restarting a couple of times because the kernel broke down it IPython console did not open.
I have installed pyPdf in the environment test-wise and importing works partly but then breaks:
import pyPdf
Traceback (most recent call last):
File "<ipython-input-1-a5780a4295f9>", line 1, in <module>
import pyPdf
File "/home/cord/.anaconda3/envs/test/lib/python3.5/site-packages/pyPdf/__init__.py", line 1, in > <module>
from pdf import PdfFileReader, PdfFileWriter
ImportError: No module named 'pdf'
This might also related to pyPdf but let's put my question more generally away from debugging third party packages:
If you wanted to use Spyder and Anaconda on a Linux-System working on different Anaconda environments, what would be the steps to install Spyder and later change between the environments?
There's no easy way right now, except changing interpreters in Python interpreter
.
However, when we add the possibility to associate a conda env to a project, then you would only need to create a project for your code, and decide what modules you'd like to use in your project (we'll also provide a graphical interface to install conda packages).
Does that sound good?
There's no easy way right now, except changing interpreters in Python interpreter.
However, when we add the possibility to associate a conda env to a project, then you would only need to create a project for your code, and decide what modules you'd like to use in your project (we'll also provide a graphical interface to install conda packages).
Does that sound good?
:+1:
The only thing I'd be interested in would then be the planned release date :smile:
This will be part of Spyder 3.3, to be released by the end of the summer.
Thanks!
@ckaldemeyer, please leave this one open so we don't forget to address it in 3.3 ;-)
@ckaldemeyer, please leave this one open so we don't forget to address it in 3.3 ;-)
:+1:
Spyder IDE specific enviroment workaround by attaching Spyder IDE to a running enviroment kernel
Preliminary: need to install ipykernel into the specific enviroment @ckaldemeyer has this as above. I've found it useful to add a descriptive name when installing the kernel, that way when changing kernels in Jupyter notebook it makes straightforward the environment you are working with:
(bioset) anne@linux:~> python -m ipykernel install --user --name bioset --display-name "Python (bioset-numpy)"
Get a list of your kernels (so you know which one to use)
anne@linux:~/anaconda3/envs> jupyter kernelspec list
Available kernels:
my_env /home/anne/.local/share/jupyter/kernels/my_env
python3 /home/anne/anaconda3/share/jupyter/kernels/python3
Launch Jupyter qtconsole (console, notebook) using the kernel associated with the enviroment you want to work with (ie the output from jupyter kernelspec list). If working with jupyter notebook, you can just launch the notebook normally and change the kernel on the right side.
jupyter qtconsole --kernel my_env
Within the qtconsole (console, notebook) spawned from the step above use a magic number command to get all of the information you need for a connection
%connect_info
The output from the magic number (%connect_info) at the end, lists the name of the kernel.json file you can use to attach, on linux its normally automatically saved to /run/user/"your user id"/jupyter if you added the kernel to the environment as a user. Alternatively copy the connection port information within the curly braces (including the curly braces) of the output %connect_info and save it as .json file.
Use Spyder IDE to connect to already running kernel:
From within the Spyder IDE-> select the gear icon in the IPython Console panel-> dropdown menu: Connect to an existing kernel-> Browse to the .json file created in the step above.
Spyder will now be using the kernel specific to your environment. Because you can use multiple IPython console tabs, you can run/test code against different environments by just changing the tabs of the IPython console
Is there anything wrong with doing something like the following to invoke spyder with a specific environment?
Install spyder in an existing second anaconda env (e.g. an env running Intel Python 3 vs. my vanilla 2.7).
Create an alias to spyder in that env folder.
alias spyder3='~/anaconda/envs/idp3/bin/spyder'
Call that alias to open spyder in that env.
Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 10:37:05)
Type "copyright", "credits" or "license" for more information.
I've been doing this to run spyder within alternate envs without problems. Is this OK, or have I just been lucky?
Is there anything wrong with doing something like the following to invoke spyder with a specific environment?
That is ok. In fact, there's a similar mechanism for Windows users provided automatically by Anaconda (i.e. Anaconda creates Start menu entries for each Spyder package in different envs).
We simply want to avoid this process and let users work with a single Spyder version for all their projects.
Hi all,
I use the Python 3.6. After I create a new ENV of Python 3.5 I have the same problem by switching Spyder between different ENVs. But I figure out. Here is what I did:
1.
Create a new env with:
conda create --name py35 python=3.5
2.
Change to the new created env with:
activate py35
3.
Install the Spyder with:
conda install spyder
4.
Start the Spyder and change the python.exe setting in Tools -> Preferences -> Python Intepreter -> Use the following Python Intepreter and select the Python.exe in the new created env.
Then close the Spyder
5.
Now start the Spyder but not the one from Python 3.6, but the one (double click the spyder.exe) from the new created ENV.
That's all.
Hi Everyone;
Would you help me out about the python console is absent as a pane in spyder 3.6? I set up Anaconda 3 64 bit in my pc but I couldnt see the pane of python console in tool or view as a pane option. Thanks
@besli, the Python console was removed in Spyder 3.2: #4524.
how about the Spyder 3.6?
3.6 is the Python version, not the Spyder version.
sorry about that... I mean spyder 3.2.6. i cant see the phyton console in spyder 3.2.6.
3.2.6 came after 3.2, so it doesn't have it either.
El 25/02/18 a las 14:58, besli escribiĂł:
>
sorry about that... I mean spyder 3.2.6. i cant see the phyton console
in spyder 3.2.6.—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
https://github.com/spyder-ide/spyder/issues/4223#issuecomment-368339383,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWS7bs1Aim2wPkqLZ0vaKZq3YrYWDxZks5tYbtogaJpZM4MSXT5.
how can i add it in that version?
is there anyone to help me out about this manner?
@besli, the Python console was removed, it's not hidden, it was simply removed, so you can't add it back. So please stop your comments here because there's nothing you can do about it.
I saw that the 3.2. Spyder has the python console in a video on youtube
hi again;
I have a problem here. I am receiving the syntax error in Iphone console. the problem is at the end of the program, i want the program quit if user response is 'No' or 'no'
thank you all.....
b=['a', 'b', 'c', 'd']
i=0
for c in b:
i=i+1
print('Exercise', i,'is',c )
a = input('Which exercise they would you like to run?')
print('Running Exercise '+ a +'')
while True:
d = input('Would you like to run another exercise?')
if d=='yes' or 'Yes':
f=input('Which exercise they would you like to run?')
print('Exercise '+ f +'')
elif d=='no' or 'No':
break
I followed steps by thomas2004ch and it worked for me. I started spyder from my created environment by typing spyder on the prom spyder started and when I checked preference->python interpreter it was already set to use the python version 2.7 under the environment that I created.
Install and run spyder from your new conda env, works for me!
If I have 2 environments but I need to use both within a project, is there no way to switch between the environments within the Spyder IDE ? Similar to how we can modify the current working directory, can we have the ability to switch between environments ?
is there no way to switch between the environments within the Spyder IDE ?
We'll add a UI for this in Spyder 4. @goanpeca knows how to do it.
Yes, we will provide two ways of doing this,
In the current version 3.3.5 can we change the interpreter inside Preferences to the virtual environment? When I change to the python interpreter in Preferences and open a new console I get this message:
An error ocurred while starting the kernel
Traceback (most recent call last):
File "C:UsersbjwilAnaconda3envsoetoolkitslibrunpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:UsersbjwilAnaconda3envsoetoolkitslibrunpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:UsersbjwilAnaconda3Libsite‑packagesspyder_kernelsconsole__main__.py", line 11, in
start.main()
File "C:UsersbjwilAnaconda3Libsite‑packagesspyder_kernelsconsolestart.py", line 297, in main
from ipykernel.kernelapp import IPKernelApp
File "C:UsersbjwilAnaconda3Libsite‑packagesipykernel__init__.py", line 2, in
from .connect import *
File "C:UsersbjwilAnaconda3Libsite‑packagesipykernelconnect.py", line 18, in
import jupyter_client
File "C:UsersbjwilAnaconda3Libsite‑packagesjupyter_client__init__.py", line 4, in
from .connect import *
File "C:UsersbjwilAnaconda3Libsite‑packagesjupyter_clientconnect.py", line 23, in
import zmq
File "C:UsersbjwilAnaconda3Libsite‑packageszmq__init__.py", line 47, in
from zmq import backend
File "C:UsersbjwilAnaconda3Libsite‑packageszmqbackend__init__.py", line 40, in
reraise(*exc_info)
File "C:UsersbjwilAnaconda3Libsite‑packageszmqutilssixcerpt.py", line 34, in reraise
raise value
File "C:UsersbjwilAnaconda3Libsite‑packageszmqbackend__init__.py", line 27, in
_ns = select_backend(first)
File "C:UsersbjwilAnaconda3Libsite‑packageszmqbackendselect.py", line 27, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:UsersbjwilAnaconda3Libsite‑packageszmqbackendcython__init__.py", line 6, in
from . import (constants, error, message, context,
ImportError: cannot import name 'constants'
@BJWiley233, your error is not related to this issue, so I'm going to hide your message and ask you to open a new issue about it.
Hello, can I get any information on whether the "assign different python environment to each project" feature made it to the 3.3?
I am asking because i cannot find the mentioned feature anywhere.
I am currently using Spyder version 3.3.4
Hello!
Thanks for that discussion. I was running Spyder 4.0.0.b5, trying to run a project in a venv. When I try to launch the ipython console, the connection to kernel never ends. I've read other similar issues on MacOS, asking to change version of ipykernel, I tried it (even if I'm running Windows X) but is had no effect.
Reverting to Spyder 3.X, I realize that I have the same issue.
I'm sorry, I have no idea what changed in my config (I tried with a completely new environment, only installing spyder-kernels and ipykernel in it) and the problem is still there... I can't run spyder in a venv.
Last try, running spyder from the venv failed.
Any held would be really appreciated!
--
BTW, I tried to use Pycharm to continue using an IDE, and I faced kind of a similar issue with an error in import _ssl
(sorry, once again I'm not sure where the error came from). The problem may come from a similar cause...
Hi, this is not the right place to ask for this. Please open a new issue about it.
Sorry . Done in #10346.
Thanks for your reactivity, and the work achieved in general.
Yes, we will provide two ways of doing this,
- One via the environment switcher from the status bar (or from the Generic Switcher) to avoid the need to go into preferences
- One associated to projects which will support conda envs (by default)
Hi, just installed Spyder 4.0.0 on Windows but struggle to find the described functionality. Could you briefly explain where I can find them?
You can clearly see that this issue is not closed. Therefore, it was not solved in Spyder 4.
the best way I found is to :
conda install spyder
then conda install conda-navigator
conda install spyder-kernels=0.*
and:
anaconda-navigator
then select the env in the top window
then start spyder
the best way I found is to :
conda install spyder
then conda install conda-navigator
conda install spyder-kernels=0.*and:
anaconda-navigatorthen select the env in the top window
then start spyder
Brilliant - that's the answer right there! Much appreciated.
This is also related with what @mrclary suggested we do to make the python interpreter configuration option in the preferences leaner.
I would like to hear your thoughts :-p .
I also agree we should probably use envs in general instead of interpreters, but there might be cases where one still needs to point to a specific interpreter.
Also some pointers, what should be the default behavior when switching to a different env (from the status bar), restart the consoles? only the current one? ask the user? add an option on preferences to do it automatically or ask the user all the time?
Also some pointers, what should be the default behavior when switching to a different env (from the status bar), restart the consoles? only the current one? ask the user? add an option on preferences to do it automatically or ask the user all the time?
What do you mean "switching to a different env (from the status bar)"? Do you mean just updating the status bar when switching console tabs? Presently, switching "interpreters" in the preferences only affects new console tabs, leaving existing console tabs in the environment (interpreter) they were started with; I think this is good. But it would be nice if the "interpreter" status in the status bar updated to reflect the current console tab, similar to the git status when switching editor documents.
Like what VSCode does.
Going to the preferences the way it is now it is very cumbersome and I would say a very bad UX. But changing the env and not having some immediate effect for it or even a option of what to do when that happens will provide still a very bad user experience.
Yeah, that would be really nice. My vote would be to always restart the current console or just start a new console with that environment.
The way VSCode changes the interpreters is very efficient and was hoping this was introduced in spyder. When will it be available?
Most helpful comment
Yes, we will provide two ways of doing this,