r/JupyterNotebooks Oct 31 '24

Jupyter not honoring Conda environments?

1 Upvotes

Hi all!

I've been using jupyter on an off for a while, but I need to start using it a lot more regularly, and I need to integrate with conda virtual environments.

Working on a new ubuntu 24.04 install, I installed Anaconda, then created a new virtual environment and installed jupyter:

conda create -n jupyter python=3.12
conda activate jupyter
pip install jupyterlab
jupyter lab
... 

So far so good, everything running as expected. So I then create another conda environment for a new project and register it with jupyter via ipykernel.

conda create -n rag-llama3.2 python=3.11
conda activate rag-llama3.2
python -m ipykernel install --user --name=rag-llama3.2

The ipykernel part was completely new to me, I was following a medium post: https://medium.com/@nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084

So I now have jupyter running in its own conda env, and a new env to use for my project. This is where things get very strange. I jump in to the jupyter console, create a new notebook, and select the newly registered kernel from the dropdown, all seems fine. I start installing a few packages and writing a little code:

! pip install langchain-nomic
! pip install -qU langchain-ollama
! pip list | grep langchain
langchain-core            0.3.14
langchain-nomic           0.1.3
langchain-ollama          0.2.0

Packages installed, so I begin with an import:

# LLM using local Ollama

### LLM
from langchain_ollama import ChatOllama

local_llm = "llama3.2:3b-instruct-fp16"
docker_host = "http://127.0.0.1:11434"

llm = ChatOllama(model=local_llm, temperature=0, api_base_url=docker_host)
llm_json_mode = ChatOllama(model=local_llm, temperature=0, format="json", api_base_url=docker_host)

Computer says no!

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[4], line 4
      1 # LLM using local Ollama
      2 
      3 ### LLM
----> 4 from langchain_ollama import ChatOllama
      6 local_llm = "llama3.2:3b-instruct-fp16"
      7 docker_host = "http://127.0.0.1:11434"

ModuleNotFoundError: No module named 'langchain_ollama'---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[4], line 4
      1 # LLM using local Ollama
      2 
      3 ### LLM
----> 4 from langchain_ollama import ChatOllama
      6 local_llm = "llama3.2:3b-instruct-fp16"
      7 docker_host = "http://127.0.0.1:11434"

ModuleNotFoundError: No module named 'langchain_ollama'

So the modules are installed, but I can't import them. At this point I started hunting around and found a few commands to help identify the problem:

!jupyter kernelspec list --json

{
  "kernelspecs": {
    "python3": {
      "resource_dir": "/home/gjws/anaconda3/envs/jupyter/share/jupyter/kernels/python3",
      "spec": {
        "argv": [
          "python",
          "-m",
          "ipykernel_launcher",
          "-f",
          "{connection_file}"
        ],
        "env": {},
        "display_name": "Python 3 (ipykernel)",
        "language": "python",
        "interrupt_mode": "signal",
        "metadata": {
          "debugger": true
        }
      }
    },
    "rag-llama3.2": {
      "resource_dir": "/home/gjws/.local/share/jupyter/kernels/rag-llama3.2",
      "spec": {
        "argv": [
          "/home/gjws/anaconda3/envs/rag-llama3.2/bin/python",
          "-Xfrozen_modules=off",
          "-m",
          "ipykernel_launcher",
          "-f",
          "{connection_file}"
        ],
        "env": {},
        "display_name": "rag-llama3.2",
        "language": "python",
        "interrupt_mode": "signal",
        "metadata": {
          "debugger": true
        }
      }
    }
  }
}
/home/gjws/anaconda3/envs/jupyter/bin/python{
  "kernelspecs": {
    "python3": {
      "resource_dir": "/home/gjws/anaconda3/envs/jupyter/share/jupyter/kernels/python3",
      "spec": {
        "argv": [
          "python",
          "-m",
          "ipykernel_launcher",
          "-f",
          "{connection_file}"
        ],
        "env": {},
        "display_name": "Python 3 (ipykernel)",
        "language": "python",
        "interrupt_mode": "signal",
        "metadata": {
          "debugger": true
        }
      }
    },
    "rag-llama3.2": {
      "resource_dir": "/home/gjws/.local/share/jupyter/kernels/rag-llama3.2",
      "spec": {
        "argv": [
          "/home/gjws/anaconda3/envs/rag-llama3.2/bin/python",
          "-Xfrozen_modules=off",
          "-m",
          "ipykernel_launcher",
          "-f",
          "{connection_file}"
        ],
        "env": {},
        "display_name": "rag-llama3.2",
        "language": "python",
        "interrupt_mode": "signal",
        "metadata": {
          "debugger": true
        }
      }
    }
  }
}

!which -a python
/home/gjws/anaconda3/envs/jupyter/bin/python

So to my untrained eyes, jupyter is seeing both the jupyter conda environment and the rag-llama3.2 environment and getting confused.

Now I don't know where to go.

Have I done something fundamentally wrong?

Should I NOT be running jupyter in its own venv and just install it globally?

Have I screwed up the ipykernel steps somewhere?

Any help would be much appreciated. I've been at this for hours and have hit a brick wall :(

Thanks for taking the time to read all this!!!


r/JupyterNotebooks Sep 17 '24

Hey, I've create a webapp to convert notebook to python + a requirements.txt with all the packages use by the notebook

6 Upvotes

r/JupyterNotebooks Aug 29 '24

MinusX: AI assistant for Jupyter

4 Upvotes

MinusX in Action

Hey Folks!
I'm Vivek, building MinusX (https://minusx.ai) . It is an AI assistant for Jupyter. It is a chrome extension that adds a side chat to analytics apps. When you give it an instruction, it operates the tool - by clicking and typing - just like you would, to analyze data and answer queries. I was a research engineer at comma.ai (used to use jupyter everyday) for the last 3 years, and this project was born out of a personal itch.

You can inter-operate with the "agent" in your notebooks and take back control anytime. Our architecture makes the agent tool agnostic, and we're looking to support more tools!

We just did a beta release of MinusX recently. You can try it on your own data on your jupyter instances right now (https://minusx.ai/chrome-extension)! I'd love to hear any feedback you may have!
PS: We're open sourcing our entire application this week!


r/JupyterNotebooks Jul 05 '24

Scope Boundaries for Notebooks — Research Study on an extension I've been developing

2 Upvotes

Hi Everyone. My name is Eric Rawn. I’m a PhD student at UC Berkeley working with my advisor Professor Sarah Chasins. I research how to make notebook programming environments better, and have been working on an extension for notebooks which introduces scope boundaries to collections of cells. We think this might help programmers avoid some of the pain points with notebooks, but we won’t know until we study its use in the real world. The goal is to make it easier to keep variables tidy within a notebook without requiring programmers to change how they like to use notebooks. We’re interested in evaluating how our extension aids how real users program (you all!), and so we’re running a 4-6 week study with folks who use Jupyter notebooks regularly in their everyday programming.

The extension will log some usage data locally on your machine, which you'll send to me at the end of the study. We'll then spend about an hour chatting about your experience, the kind of work you do daily, how you use notebooks, and any other thoughts or feedback you have. Participants will be compensated for their time spent interviewing, at $30/hour. The consent form has detailed information about the study if you’re interested. I care a lot about protecting the privacy of my participants, and so a lot of the consent form (and our first chat together at the beginning of the study) is dedicated to explaining exactly what data will be collected, how it will be used, and addressing any questions or concerns.

The extension is already open source on Github (linked below), but a full release will be out on PyPi after we can incorporate what we learned from the study. If you like the extension, you’re of course welcome to continue using it after the study ends! 

If you’re interested in participating, please fill out this interest form

If you’re curious about the tool, you can check out the GitHub page: https://github.com/erawn/pagebreaks for a preview of the interface. 

If you have any questions at all, feel free to send me an email at [erawn@berkeley.edu](mailto:erawn@berkeley.edu), and feel free to forward this to anyone you think might be interested! Thanks!


r/JupyterNotebooks Jun 11 '24

Jupyter Notebooks Vs Rstudio BioMart getBM Issue

1 Upvotes

I have been using jupyter notebooks quite often and I really like that it is rendered properly on Github. However, for whatever reason when use certain software such as BioMart it does not work well in Jupyter notebooks. For example the command `getBM` does not work in my jupyter notebooks but does work in my Rstudio on the same laptop. I was wondering if anyone has experienced this issue and if there is a work around they use in Jupyter Notebooks to get it to work. The same commands were used in Rstudio and Jupyter notebooks so it is not an issue with the commands.


r/JupyterNotebooks Jun 02 '24

Python notebooks for fundamentals of music processing

Thumbnail audiolabs-erlangen.de
2 Upvotes

r/JupyterNotebooks May 31 '24

A new ETL extension for Jupyterlab

5 Upvotes

Hi Jupyter community!

I wanted to share with you an extension I have developed called Amphi.

Discover Amphi for Jupyterlab

Github: https://github.com/amphi-ai/amphi-etl (⭐ Leave a star if you like it!)

In short, Amphi is a low-code and python-based ETL extension for Jupyterlab. You can install it from the extension manager or using pip in your environment:

pip install --upgrade jupyterlab-amphi

ETL extension for Jupyterlab (Amphi)

Amphi key features:

  • 🧑‍💻 Low-code: Design data pipelines using graphical components.
  • 🐍 Python-code Generation: Generate native Python code leveraging common libraries such as pandas, DuckDB and LangChain that you can use anywhere (in your notebooks or applications).

Amphi stands out by supporting both structured and unstructured data to address AI use cases such as RAG pipelines in particular.

  • 🔢 Structured: Import data from various sources, including CSV and Parquet files, as well as databases. Transform structured data using aggregation, filters, joins, SQL queries, and more. Export the transformed data into common files or databases.
  • 📝 Unstructured: Extract data from PDFs, Word documents, and websites (HTML). Perform parsing, chunking and embedding processing. Load the processed data into vector stores such as Pinecone and ChromaDB.
  • 🔁 Convert: Easily convert structured data into unstructured document for vector stores and vice versa for RAG pipelines.

Visit the GitHub or Slack to ask questions, propose features, or contribute.
Let me know what you think!


r/JupyterNotebooks May 25 '24

Help needed. Problem with my jupyter notebook.

2 Upvotes

Well i installed conda and when i open jupyter notebook it looks like this:

It didnt use to look like that. Now its just ugly. The problem happened after i uninstalled anaconda and reinstalled it.


r/JupyterNotebooks May 17 '24

A Kalman filter playground

Thumbnail juangburgos.github.io
3 Upvotes

r/JupyterNotebooks May 10 '24

Jupyter Themes Not Working Recently?

4 Upvotes

Today, out of nowhere, my anaconda Navigator would not launch in Windows 10, so I uninstalled/reinstalled it. This fixed that issue, but when I boot up the Anaconda Navigator --> Jupyter Notebook, open Notebook,
pip install jupyterthemes
!jt -t monokai -T -N -kl

it runs fine, but when I refresh it is still set to setting light theme and nothing changed (I can change the theme in the settings bar only to light or dark). I have tried restarting my machine, closing the browser, clearing the browser cache, running the jt -t monokai -T -N -kl command in anaconda prompt (seems to run fine there with no errors), but nothing is changing my theme anymore to monokai. Anyone know if this is a problem with some recent change or if I have something setup wrong?


r/JupyterNotebooks May 08 '24

How to run python code from Javascript in Jupyterlab

1 Upvotes

My usecase is to get access and refresh tokens from the browser cookie or local storage using the jupyterlab cell. I have found a way to do this, but it is not working properly. I have followed the following steps

  1. Enabled jupyterapp c.LabApp.expose_app_in_browser = True
  2. Running the following code to get cookies from the browserfrom IPython.display import display, Javascript

from IPython.display import display, Javascript
js_code = """
async function run() {
    const session = jupyterapp.shell.currentWidget.context.sessionContext.session;
    const kernel = jupyterapp.serviceManager.sessions._connectToKernel({model: {id: session._kernel._id, name: session._kernel._name}})
    const cookies = document.cookie.split(';').reduce((acc, cookie) => {
        const [name, value] = cookie.trim().split('=');
        acc[name] = value;
        return acc;
    }, {});
    await kernel.requestExecute({code: `
    globals()["access"] = '${cookies.access}';
    globals()["refresh"] = '${cookies.refresh}';
    `}).done;
    console.log("executed")
}

run()
"""
display(Javascript(js_code))
print(globals()['access'])
print(globals()['refresh'])

Now the values of globals()['access'] and globals()['refresh'] are empty because the above kernel.requestExecute() is an async function, it takes sometime to resolve the request. But I am not able to get these values even after adding a timeout.

It is working if I print this in another cell of jupyterlab after sometime. Is there any way to achieve the above?

Thank you,


r/JupyterNotebooks Apr 10 '24

Way to namespace your code sections in jupyter notebook?

1 Upvotes

Often I do some calculation, cell by cell.

Then I want to do a similar calculation. I mark off a new section with markdown, and then proceed cell by cell. This continues for a few similar calculations.

Finally, I want to compare results from each of these different sections.

This becomes rather verbose because now I have the same variables in each section that I have to manually namespace.

e.g. in the first section I use experimentHallEffect_voltagein my second section I use experimentMeisnerEffect_voltage

Is there some way I could name space them, and still have the cell environment? something like:

Namespace experimentHallEffect

voltage = f(...)

Cell that calculates something

voltage = g(voltage+8)

And then a new section

And a new cell

Namespace experimentMeisnerEffect

voltage = q(...)

r/JupyterNotebooks Mar 09 '24

Install and use autocomplete in jupyter lab 4.1.2

1 Upvotes

I'm using jupyter lab 4.1.2. is there like an extension that can suggest code while I'm typing my code in jupyter lab. I tried installing tabnine and hinterland extension, but it seems like it's disabled. I checked the list of extensions installed using cmd and even though these extensions are listed there, these won't work in the jupyter lab environment.


r/JupyterNotebooks Feb 23 '24

Why am I getting " 'TableList' object has no attribute 'columns'?

1 Upvotes

I have a code that uses 2MASS and Gaia databases and I have it scan 2MASS data and combine/sort through my Gaia dataframe to find matches. However when I run it, I get the error " Why am I getting " 'TableList' object has no attribute 'columns'?" Why?

df = gaia_v2 #change to desired dataframe
twomass_matches = []
for i in range(0, len(df)):
    result = Vizier(columns=["**"], catalog="II/246").query_region(SkyCoord(ra=df['ra'][i], dec=df['dec'][i],
                                                                                unit=(u.deg, u.deg)), radius='20s')
    if len(result) == 0:
        values = [np.nan for i in range(0, 62)]
        twomass_matches.append(values)
    else:
        result = result[0]

        if len(result) == 1:
            values = [result[colname][0] for colname in result.columns]
            twomass_matches.append(values)
        else:
            diffs = [(((df['ra'][1]-result['RAJ2000'][j])**2)+(df['dec'][i]-result['DEJ2000'][j])**2) for j in range(0, len(result))]
            index = diffs.index(min(diffs))
            values = [result[colname][index] for colname in result.columns]
            twomass_matches.append(values)

colnames = result.columns
for i in range(0, len(colnames)):
        values = [twomass_matches[j][i] for j in range(0, len(twomass_matches))]
        df[colnames[i]] = values
gaia_2mass = df

gaia_2mass.to_csv("2MASS_data") #insert desired filename to download as csv


print (gaia_2mass)



#full error is 
AttributeError                            Traceback (most recent call last)
Cell In[53], line 21
     18             values = [result[colname][index] for colname in result.columns]
     19             twomass_matches.append(values)
---> 21 colnames = result.columns
     22 for i in range(0, len(colnames)):
     23         values = [twomass_matches[j][i] for j in range(0, len(twomass_matches))]


r/JupyterNotebooks Feb 22 '24

Update: I built a way to visualize Jupyter notebook diffs!

Thumbnail gallery
8 Upvotes

r/JupyterNotebooks Jan 19 '24

Leveraging Jupyter for dynamic streaming data visualization in financial trading: Stock prices captured from Polygon.io API into CSV for easy showcase of Nb, followed by live data processing with open-source Python libs: Pathway for batch/stream processing, Panel & Bokeh for visualization. Thoughts?

Thumbnail colab.research.google.com
5 Upvotes

r/JupyterNotebooks Jan 15 '24

Trying to build a souped-up programming environment for Jupyter notebooks! I would love to hear your thoughts

3 Upvotes

r/JupyterNotebooks Jan 08 '24

are jupyter plot just image?

2 Upvotes

I'm writing a Jupyter Notebook for a lab report template school project. The idea is to share the template with the students, and have good reports back. I'm quite new on Jupyter, sorry for the newbie question ... Once I create a plot (using matplotlib for example) I get it as an IMAGE in the notebook. I can't pan,zoom in-out, I can't have a cursor in the plot. Am I'm missing something or this is it? Is there a way to have an "iteractive" plot as output?

Thanks


r/JupyterNotebooks Dec 30 '23

An issue with exporting pdfs

2 Upvotes

Hey guys, I'm trying to export a file from jupyter notebook to a pdf format, but for some reason I keep getting server error message stating that "nbconvert failed: PDF creating failed, captured latex output: Failed to run "xelatex notebook.tex -quiet" command: ". Other ipynb files that were in the same folder as this one exported normally. Does anyone have any ideas for why that it? Thanks.


r/JupyterNotebooks Dec 23 '23

Any idea guys how to enable this ?

Post image
1 Upvotes

r/JupyterNotebooks Dec 11 '23

Upcoming open community call

1 Upvotes

Hi r/JupyterNotebooks, u/ericsnekbytes here (from the JupyterLab and Jupyter Notebook councils)

We want to see all the cool things you're doing with Jupyter, so we're holding an open call with the community for people to chat, and share their creations and work. Think of it as a "virtual JupyterCon": It's a place to announce and share fun things happening in the Jupyter community.

Event Details:

December 13, 2023, at 9:00AM PST (your timezone)

We meet on Zoom (over video) and:

  • Anyone can attend (for free!) 👩🏾‍🚒 👨🏼‍🍳 👨🏽‍🎤 👩🏻‍🚀 👮🏻‍♂️ 🕵🏾‍♀️ 👨🏿‍💻 👩🏻‍⚕️ 👩🏼‍🌾 👨🏻‍⚖️ 👩🏽‍🔬
  • 🖼 Anyone can present (add yourself the agenda above)
  • 👀 Anyone can just sit in on the call.
  • Presenters will lead a demo and spend a few minutes answering questions
  • Topics will be targeted at a broad Jupyter audience (not overly technical)

Watch previous calls from this YouTube Playlist.


r/JupyterNotebooks Dec 09 '23

Jupyter highlight

1 Upvotes

Hi all, i'm pretty new on jupyter. I was using notebook 6.5.4 version on Chrome, today I updated to 7.0.6 version, but python function like range() are no longer highlighted.

How can i solve this issue? Thank you.


r/JupyterNotebooks Nov 10 '23

Jupyter Notebook from local to remote

1 Upvotes

Hello,

What's the best way to migrate a user from using Jupyter Notebook locally to remotely? In other words, this user has always used Jupyter Notebook on the local computer due to its resources, but we're going through some changes that are going to prevent the user from logging into the computer locally.

I have come across Jupyter Hub, but then I'm not clear on how to "offload" the Notebook processing to the computer that has the resources. The box that we'd install Jupyter Hub on would not be the same as the one that the Notebooks are executed on.

Is this the best approach or is there a better suggestion?


r/JupyterNotebooks Nov 08 '23

keep track of all versions of variable values corresponding to a version (commit) of code in jupyter notebook

Thumbnail self.learnpython
1 Upvotes

r/JupyterNotebooks Jun 12 '23

r/JupyterNotebooks will participate in the 48-hour blackout

2 Upvotes

Hi everyone, u/afatsumcha here.

After checking with our other moderator, r/JupyterNotebooks will be participating in the 48-hour protest against API charges.

Charging for API access limits users' ability to interact with Reddit, and prevents some Reddit interfaces (e.g. Apollo) from being feasible to run at all.