# \[TLJH\] Environment PATH different in notebook than terminal

**URL:** <https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255>\
**Category:** The Littlest JupyterHub\
**Tags:** how-to\
**Created:** [August 4, 2021, 9:44pm UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255 "2021-08-04T21:44:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![francois](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@francois](https://discourse.jupyter.org/u/francois)\
**Post date:** [August 4, 2021, 9:44pm UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255/1 "2021-08-04T21:44:40Z")

</div>

What am I missing?  
in the notebook:  
! echo $PATH

> /opt/tljh/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

open a terminal from launcher and type **echo $PATH**

> /home/jupyter-hubadmin/bin:/usr/local/cuda/bin:/opt/tljh/user/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

the terminal pickup my .profile export PATH cmd and cuda BUT NOT the notebook  
**What gives ?**

---

<div class="post-metadata">

**Author:** ![fperez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fperez/32/148_2.png) [@fperez](https://discourse.jupyter.org/u/fperez)\
**Post date:** [August 5, 2021, 3:51am UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255/2 "2021-08-05T03:51:56Z")

</div>

I can provide more details later, but [this comment](https://discourse.jupyter.org/t/permissions-in-terminal/10201/3) might get you going in the right direction (it’s not exactly the same issue, but the underlying mechanisms apply similarly in your case).

---

<div class="post-metadata">

**Author:** ![francois](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@francois](https://discourse.jupyter.org/u/francois)\
**Post date:** [August 5, 2021, 4:46pm UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255/3 "2021-08-05T16:46:41Z")

</div>

Thank-you for the read fperez - but it did not change anything -

- yes, i have restarted server even rebooted

There is a configuration somewhere that add “/opt/tljh/user/bin” to the PATH variable  
I even ran  
root@jupyterhub:/opt/tljh# grep -r “/opt/tljh/user/bin” \*  
but nothing indicative showed-up

---

<div class="post-metadata">

**Author:** ![fperez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fperez/32/148_2.png) [@fperez](https://discourse.jupyter.org/u/fperez)\
**Post date:** [August 5, 2021, 6:09pm UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255/4 "2021-08-05T18:09:01Z")

</div>

Here’s a trick you can use to debug this… Add an environment variable in _each_ of your startup files (say $RAN\_BASHRC in .bashrc, $RAN\_BASH\_PROFILE in .bash\_profile, etc.). Then search for these variables in your environment both via `!env grep RAN` and in the keys of `os.env`, and also in a normal terminal.

This will help you pin down exactly which files are getting run in each case… You can then try to organize the layout of your configuration in the files that get loaded…

---

<div class="post-metadata">

**Author:** ![francois](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@francois](https://discourse.jupyter.org/u/francois)\
**Post date:** [August 5, 2021, 6:09pm UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255/5 "2021-08-05T18:09:36Z")

</div>

I found my solution  
jupyter kernelspec list  
Available kernels:  
python3 /opt/tljh/user/share/jupyter/kernels/python3

**Modify**  
“/opt/tljh/user/share/jupyter/kernels/python3/kernel.json”  
**add this line:**  
“env”: {“LD\_LIBRARY\_PATH”:“/usr/local/cuda/lib64”,“PATH”:“/usr/local/cuda/bin:${PATH}”} ,

> {  
> “argv”: [  
> “/opt/tljh/user/bin/python”,  
> “-m”,  
> “ipykernel\_launcher”,  
> “-f”,  
> “{connection\_file}”  
> ],  
> “env”: {“LD\_LIBRARY\_PATH”:“/usr/local/cuda/lib64”,“PATH”:“/usr/local/cuda/bin:${PATH}”} ,  
> “display\_name”: “Python 3”,  
> “language”: “python”  
> }

**now** nvcc --version **works**

---

<div class="post-metadata">

**Author:** ![fperez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fperez/32/148_2.png) [@fperez](https://discourse.jupyter.org/u/fperez)\
**Post date:** [August 5, 2021, 6:10pm UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255/6 "2021-08-05T18:10:09Z")

</div>

That does it too, great! 🙂 Thanks for sharing this solution, it will help others in the future!

---

<div class="post-metadata">

**Author:** ![francois](https://avatars.discourse-cdn.com/v4/letter/f/77aa72/32.png) [@francois](https://discourse.jupyter.org/u/francois)\
**Post date:** [August 5, 2021, 6:11pm UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255/7 "2021-08-05T18:11:07Z")

</div>

It’s a hub - it needed to be global 😉

---

<div class="post-metadata">

**Author:** ![12Tall](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/12tall/32/6820_2.png) [@12Tall](https://discourse.jupyter.org/u/12Tall)\
**Post date:** [March 29, 2022, 8:44am UTC](https://discourse.jupyter.org/t/tljh-environment-path-different-in-notebook-than-terminal/10255/8 "2022-03-29T08:44:03Z")

</div>

Thanks bro, it’s very useful!!!  
But I have to use the absolute path for some environments, strange, but that’s all fine 🤣
