Closed tbress closed 3 years ago
Hey @tbress, thanks for reporting. If you want to use to other packages that don't come with our Windows installer (like Pytorch), you need to install Miniconda, create a conda environment after that with the packages you want to use and spyder-kernels
, and finally connect Spyder to that environment.
Please try that and let us know if it works for you.
Thanks, Carlos. I'm trying to follow your advice using this website: Working with packages and environments in Spyder · spyder-ide/spyder Wiki (github.com) https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder#the-modular-approach. I installed miniconda and have a base environment activated. I installed spyder-kernels in that environment. When I list the packages in the environment I see that I have spyder-kernels v1.10.2. When I point Spyder at the miniconda directory I get an error message saying "Your Python environment or installation doesn't have the spyder‑kernels module or the right version of it installed (>= 2.0.1 and < 2.1.0). Without this module is not possible for Spyder to create a console for you."
I then tried updating spyder-kernels using "conda install -c conda-forge spyder-kernels" in my base environment, but when I list the packages I still see the v1.10.2 and I still can't open a kernel in Spyder. I'm new to setting up environments, is there a step I'm missing? Thanks.
On Sun, May 2, 2021 at 7:12 PM Carlos Cordoba @.***> wrote:
Hey @tbress https://github.com/tbress, thanks for reporting. If you want to use to other packages that don't come with our Windows installer (like Pytorch), you need to install Miniconda https://docs.conda.io/en/latest/miniconda.html, create a conda environment https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#creating-an-environment-with-commands after that with the packages you want to use and spyder-kernels, and finally connect Spyder http://docs.spyder-ide.org/current/faq.html#using-existing-environment to that environment.
Please try that and let us know if it works for you.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/15486#issuecomment-830923498, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATT2ZUNCWZZTAA5L3654HW3TLXL6LANCNFSM437ZJGKA .
I'm trying to follow your advice using this website
Great! That page has a more detailed explanation than the one I provided above.
I'm new to setting up environments, is there a step I'm missing? Thanks
Ok, please then run
conda install -c conda-forge spyder-kernels=2.0.1
to force the installation of that version instead of 1.10.2
Thanks, that works. I appreciate your help, I've used Spyder for engineering and science work in the past and now I going to take a data science class and want to use Spyder as my IDE. I now have miniconda installed, and pytorch installed in the miniconda environment as well as the correct version of spyder-kernels. I can start Spyder and connect to a kernel. But when I try running the code I sent you before I still have an issue. The code completes successfully and gives me the right answer, but I still get the Spyder internal problem pop-up window. When I show the details of the internal error pop-up I get:
Exception in comms call get_namespace_view:
File "C:\Users\615237\AppData\Local\Programs\Spyder\pkgs\spyder_kernels\comms\commbase.py", line 315, in _comm_message
encoding='latin-1')
ModuleNotFoundError: No module named 'torch'
On Mon, May 3, 2021 at 12:17 PM Carlos Cordoba @.***> wrote:
I'm trying to follow your advice using this website
Great! That page has a more detailed explanation than the one I provided above.
I'm new to setting up environments, is there a step I'm missing? Thanks
Ok, please then run
conda install -c conda-forge spyder-kernels=2.0.1
to force the installation of that version instead of 1.10.2
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/15486#issuecomment-831370915, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATT2ZUI4VCTMOCLIVIWGTQLTL3EDLANCNFSM437ZJGKA .
I think you're missing the last step I mentioned above:
and finally connect Spyder to that environment.
Please follow the instructions in the link to connect your Miniconda environment to Spyder.
Thanks, Carlos. I took your advice again and came across something strange. First I rebooted my computer, then started Spyder. I had previously set my Python preference for the miniconda environment, so it started in that environment. I went through the steps of reselecting the miniconda Python environment again, there was no issue with that. But then I tried to restart the kernel as you suggested in your link. I got the following error:
Traceback (most recent call last): File "C:\Users\615237\Miniconda3\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\615237\Miniconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\615237\Miniconda3\lib\site‑packages\spyder_kernels\console__main__.py", line 23, in start.main() File "C:\Users\615237\Miniconda3\lib\site‑packages\spyder_kernels\console\start.py", line 284, in main kernel.initialize() File "C:\Users\615237\Miniconda3\lib\site‑packages\traitlets\config\application.py", line 87, in inner return method(app, *args, **kwargs) File "C:\Users\615237\Miniconda3\lib\site‑packages\ipykernel\kernelapp.py", line 567, in initialize self.init_sockets() File "C:\Users\615237\Miniconda3\lib\site‑packages\ipykernel\kernelapp.py", line 271, in init_sockets self.shell_port = self._bind_socket(self.shell_socket, self.shell_port) File "C:\Users\615237\Miniconda3\lib\site‑packages\ipykernel\kernelapp.py", line 218, in _bind_socket return self._try_bind_socket(s, port) File "C:\Users\615237\Miniconda3\lib\site‑packages\ipykernel\kernelapp.py", line 194, in _try_bind_socket s.bind("tcp://%s:%i" % (self.ip, port)) File "C:\Users\615237\Miniconda3\lib\site‑packages\zmq\sugar\socket.py", line 173, in bind super().bind(addr) File "zmq/backend/cython/socket.pyx", line 542, in zmq.backend.cython.socket.Socket.bind File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc zmq.error.ZMQError: Address in use
On Mon, May 3, 2021 at 8:09 PM Carlos Cordoba @.***> wrote:
I think you're missing the last step I mentioned above:
and finally connect Spyder http://docs.spyder-ide.org/current/faq.html#using-existing-environment to that environment.
Please follow the instructions in the link to connect your Miniconda environment to Spyder.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/15486#issuecomment-831610484, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATT2ZUNCJCIBPWBJCI3K2YTTL43LBANCNFSM437ZJGKA .
Hello, Carlos. I believe I've solved the problem. Originally I had installed Spyder before having installed miniconda. I then installed miniconda later and installed the other packages. I uninstalled Spyder and reinstalled using conda and everything works now. Thanks again for your help.
On Tue, May 4, 2021 at 12:02 PM Thomas Bress @.***> wrote:
Thanks, Carlos. I took your advice again and came across something strange. First I rebooted my computer, then started Spyder. I had previously set my Python preference for the miniconda environment, so it started in that environment. I went through the steps of reselecting the miniconda Python environment again, there was no issue with that. But then I tried to restart the kernel as you suggested in your link. I got the following error:
Traceback (most recent call last): File "C:\Users\615237\Miniconda3\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\615237\Miniconda3\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\Users\615237\Miniconda3\lib\site‑packages\spyder_kernels\console__main__.py", line 23, in start.main() File "C:\Users\615237\Miniconda3\lib\site‑packages\spyder_kernels\console\start.py", line 284, in main kernel.initialize() File "C:\Users\615237\Miniconda3\lib\site‑packages\traitlets\config\application.py", line 87, in inner return method(app, *args, **kwargs) File "C:\Users\615237\Miniconda3\lib\site‑packages\ipykernel\kernelapp.py", line 567, in initialize self.init_sockets() File "C:\Users\615237\Miniconda3\lib\site‑packages\ipykernel\kernelapp.py", line 271, in init_sockets self.shell_port = self._bind_socket(self.shell_socket, self.shell_port) File "C:\Users\615237\Miniconda3\lib\site‑packages\ipykernel\kernelapp.py", line 218, in _bind_socket return self._try_bind_socket(s, port) File "C:\Users\615237\Miniconda3\lib\site‑packages\ipykernel\kernelapp.py", line 194, in _try_bind_socket s.bind("tcp://%s:%i" % (self.ip, port)) File "C:\Users\615237\Miniconda3\lib\site‑packages\zmq\sugar\socket.py", line 173, in bind super().bind(addr) File "zmq/backend/cython/socket.pyx", line 542, in zmq.backend.cython.socket.Socket.bind File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc zmq.error.ZMQError: Address in use
On Mon, May 3, 2021 at 8:09 PM Carlos Cordoba @.***> wrote:
I think you're missing the last step I mentioned above:
and finally connect Spyder http://docs.spyder-ide.org/current/faq.html#using-existing-environment to that environment.
Please follow the instructions in the link to connect your Miniconda environment to Spyder.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/15486#issuecomment-831610484, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATT2ZUNCJCIBPWBJCI3K2YTTL43LBANCNFSM437ZJGKA .
Great! I'm really glad you were able to finally solve it!
And just so you know, we're planning to improve installing environments and packages for the future.
Description
What steps will reproduce the problem?
In the Coursera course on machine learning lab (https://www.coursera.org/learn/machine-learning-duke/ungradedLab/IP4b8/logistic-regression/lab) the following code is given. When I run it in Spyder I get an internal error:
import numpy as np
import matplotlib.pyplot as plt
import torch import torch.nn.functional as F
from tqdm.notebook import tqdm
from torchvision import datasets, transforms
Load the data
mnist_train = datasets.MNIST(root="./datasets", train=True, transform=transforms.ToTensor(), download=True) mnist_test = datasets.MNIST(root="./datasets", train=False, transform=transforms.ToTensor(), download=True) train_loader = torch.utils.data.DataLoader(mnist_train, batch_size=100, shuffle=True) test_loader = torch.utils.data.DataLoader(mnist_test, batch_size=100, shuffle=False)
Training
Initialize parameters
W = torch.randn(784, 10)/np.sqrt(784) W.requiresgrad() b = torch.zeros(10, requires_grad=True)
Optimizer (lr is the learning rate, or step size)
optimizer = torch.optim.SGD([W,b], lr=0.1)
Iterate through the training set minibatches (one epoch)
for images, labels in train_loader:
Zero out the gradient
Testing
correct = 0 total = len(mnist_test)
with torch.no_grad():
Iterate through the test set minibatches
print('Test accuracy: {}'.format(correct/total))
Traceback
Versions
Dependencies