Python Forum
Cannot get to virtual environment in Jupyter IDE
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot get to virtual environment in Jupyter IDE
#1
I am trying to use fbprophet in jupyter notebook in a program for making predictions.

To use it requires python=3.61 which means that I must make a virtual environment
since my base environment uses python 3.8.

I make the virtual environment with no problem. I then active keras-env and that works.

This is all on the command line, new -terminal.

So far everything is fine, but I must make some additional changes or the when I go back to the jupyter notebook
IDE the changes will not be recognized. The IDE has to have these commands.

conda install ipkernel
python -m ipykernel install --user --name=kerasenv.

Now I assume these last two commands above must be run in an active keras-env environment. Nowhere does it say so, but I am just assuming that it must be true.

However, when I leave the command line and go back to the jupyter notebook IDE, it does now have keras-env in the upper right hand corner. So I am assuming I did it right.

I did not!

If I use the drop down down menu and select keras-env it does say that at the upper right hand corner.

However, when I go the first jupyter notebook IDE space and type in:

!python -V

and then execute that one command, I get python 3.85, not 3.61. As I said I want the version of 3.61 because when using keras that is the only python version that works with it a far as I know.

Everything seems, but I am still in the base environment, not the virtual environment.

What am I doing wrong? I believe that I am taking the right steps, but the result is that when in the jupyter notebook IDE, I am still using python 3.85 and not python 3.61. That means I never entered the virtual environment as far as the IDE is concerned. That is what I want to use the keras-env, not my base environment.

My base environment cannot run keras because it has python 3.85.

I have included a series of screenshots that go through the steps that I discussed above.

The only thing that I can think of as being wrong is that my jupyter notebook is being run in Docker container and maybe there is something wrong there.

How I have tried many different Docker containers and it happens in all of them. I have done routine many times before, usually separated by a few months. I must relearn each time.

Any Help appreciated. Thanks in advance.

Respectfully,

ErnestTBass

Attached Files

Thumbnail(s)
                   
Reply
#2
Not help per se but from Python documentation some ideas for further troubleshooting:

Quote:When a virtual environment is active (i.e., the virtual environment’s Python interpreter is running), the attributes sys.prefix and sys.exec_prefix point to the base directory of the virtual environment, whereas sys.base_prefix and sys.base_exec_prefix point to the non-virtual environment Python installation which was used to create the virtual environment. If a virtual environment is not active, then sys.prefix is the same as sys.base_prefix and sys.exec_prefix is the same as sys.base_exec_prefix (they all point to a non-virtual environment Python installation).
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#3
Is the virtual environment activated before you start jupyter notebook?
You can use ipkernal to do this see: https://anbasile.github.io/posts/2017-06...yter-venv/
Reply
#4
I will try to activate the virtual environment on the command line before I go to the jupyter notebook IDE.

I will reply only if it fails to work.

Thank for quick response.

ErnestTBass

It did not work. If it's all the same to you, I am going to move this question o th the jupyter notebook form.

I finally have an account on it.

ErnestTBasss
Reply
#5
read the blog at link I supplied
Reply
#6
I think because I am using a Docker images that some parts of a complete
Ubuntu install are missing. I found that there was no

nb_conda_kernels

installed in the base environment so I installed it. Now a far as the two statements made after the virtual environment is created and installed with python=3.6.

These two statements

conda install ipykernel
python -m ipykernel install --user --name=keras-env
I am not sure whether they are used at all. I can eliminate the first statement by
installing ipykernel when I create and install the virtual environment. I not even sure that the
second one should be used at at all. I have seen examples where is is not used.

I have yet to get it to work, but I think I am close.

I have read your link and it seems to offer no info on this.

ErnestTBass
Reply
#7
Could you please tell me if I am on the right track with installing nb_conda_kernels?

It seems to work on the Windows 10 version of jupyter notebook, which is part of Anaconda3.

I know that nb_conda_kernels helps in distinguishing between kernels in jupyter notebook. As I said, I think that installing nb_conda_kernels in the base environment solves the issue with Windows Anaconda3 jupyter Notebook.

Just let me know if it is the right approach.

Respectfully,

ErnestTBass
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with creating folder and "virtual environment" AudunNilsen 1 171 Mar-21-2024, 04:41 AM
Last Post: deanhystad
  Installing python packages in a virtual environment Led_Zeppelin 1 712 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  Problem with virtual environment standenman 2 945 Feb-23-2023, 07:09 PM
Last Post: standenman
Question Virtual Environment (using VS Code) Ashcora 4 12,503 Feb-15-2023, 07:17 PM
Last Post: snippsat
  How do I link the virtual environment of that project to the 3.9.2 version of python? Bryant11 1 1,332 Feb-26-2022, 11:15 AM
Last Post: Larz60+
  Project structure with a virtual environment gdbengo 1 1,390 Jan-26-2022, 03:22 PM
Last Post: snippsat
  Virtual environment path? Led_Zeppelin 1 2,261 Jul-22-2021, 01:40 PM
Last Post: snippsat
  virtual environment heye 4 2,398 Jul-04-2021, 06:47 AM
Last Post: ndc85430
  import statement in a virtual environment leodavinci1990 1 2,298 Mar-04-2021, 12:57 AM
Last Post: snippsat
  Virtual environment and upgrading python 3.5 to 3.9 NeilUK 4 11,973 Jan-24-2021, 01:02 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020