#๐ How to use venv with jupyter?
67 messages ยท Page 1 of 1 (latest)
@errant hedge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
when you click on the button in the top-right, what happens?
it asks whether i want to use a python kernel or jupyter server, and if i select the first, then it just asks me to either create a new .venv or select a default global installation
๐ค
I chose the top option (I forget what it was), then it gave me the chance to choose an existing virtualenv, and the relevant one was at the top
if it just allowed me to place a certain one, it would be doable
maybe it has to do with how i created the env? with the terminal command?
why not choose the one that it shows as "Recommended"?
That's what I did, and it worked fine
id rather not use a global one, and instead have a venv for each project... At least that's what out teacher told us is best
but
and the recommended one doesnt even exist lol
if you choose the recommend one you will not be using "a global one"
what happens when you click that line anyway?
it selects the kernel, but when i try any cells it says that "it failed to start as the environment isn't available"
๐ค
but thats okay
lemme jsut restart the notebook
now there isnt even a recommended one xD
so, I've created an empty folder. I copied some random notebook into it. I "pointed" VSC at that notebook, and now I see this
which seems reasonable.
thsi is what appears for me
Yeah "Create Python Environemnt" sounds like the right choice
so i must use the env it forces me to...
๐
dunno what you mean by that
when you choose "Create Python Environment", it ... creates a virtual environment, and then uses that.
which is a good thing.
yeah
but then i cant move that one around? I dont want it to stay where it did, although when i move it around it says it no longer exists
yeah you shouldn't move virtualenvs around. But why do you want to? Just create it where you actually want it.
[I'm not sure that you can't move virtualenvs around; I've just never done it]
it automatically creates it on the bigger folder, when i want it on the one holding the notebook, but it seems vsc just detects the one in the immediate folder
this does work:
but it didnt when i had the big folder opened
big folder?
no idea what that means
when I did it, it created the virtualenv exactly where I'd expect: in the folder that I had open in vsc (which was the folder with the notebook in it)
sorry im not explaining myself that well. I mean the folder containing the folder that has the notebook
yeah, i had a full university folder opened, so it created it somewhere else
I'm so confused
here's what you should do
- figure out where you want the venv
- get the notebook, and whatever else you want, into that folder
- open vsc in that folder
- have vsc create the venv there
yeah me too... Ignoring that, now with the .venv working somewhat properly, it says that i cant pip install cause "externally-managed-environment"
thank you
sounds like you're using Debian
yeah, ubuntu
ok well that's normal
is that aproblem?
that's a sign that you're not using a virtualenv
but... it says its using one?
I didn't know VSC ran on ubuntu though
your images aren't showing up ๐
oh
just piles of poo ๐
I'd type type -a pip at that terminal
the presence of (.venv) in the prompt isn't a guarantee that everything is properly set up (although it'd have fooled me, too)
:-) 2025-02-13T12:29:39-0800 [x]$ source .venv/bin/activate
(.venv) :-) 2025-02-13T12:29:44-0800 [x]$ type -a pip
pip is /private/var/folders/b0/_p0c_57s5n90cy4njdgd8vhw0000gq/T/x/.venv/bin/pip
that output is correct
ill try it after dinner, thank you
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.