Jupyter Notebook's terminal command not using correct conda environment












0















I have 2 conda environments installed:

- env1: base environment where jupyter-notebook is installed and started from

- env2: project environment with ipykernel installed
I manually added kernelspecs for the 2 environments following this guide.



Everything works fine. sys.executable in 2 kernels show separate, correct paths. But for terminal commands (i.e. !which python), no matter which kernel I'm running in the environment defaults to env1.



Is there any way to have the notebook automatically change this to the kernel's environment?



P.S. I already tried installing nb_conda, nb_conda_kernels










share|improve this question





























    0















    I have 2 conda environments installed:

    - env1: base environment where jupyter-notebook is installed and started from

    - env2: project environment with ipykernel installed
    I manually added kernelspecs for the 2 environments following this guide.



    Everything works fine. sys.executable in 2 kernels show separate, correct paths. But for terminal commands (i.e. !which python), no matter which kernel I'm running in the environment defaults to env1.



    Is there any way to have the notebook automatically change this to the kernel's environment?



    P.S. I already tried installing nb_conda, nb_conda_kernels










    share|improve this question



























      0












      0








      0








      I have 2 conda environments installed:

      - env1: base environment where jupyter-notebook is installed and started from

      - env2: project environment with ipykernel installed
      I manually added kernelspecs for the 2 environments following this guide.



      Everything works fine. sys.executable in 2 kernels show separate, correct paths. But for terminal commands (i.e. !which python), no matter which kernel I'm running in the environment defaults to env1.



      Is there any way to have the notebook automatically change this to the kernel's environment?



      P.S. I already tried installing nb_conda, nb_conda_kernels










      share|improve this question
















      I have 2 conda environments installed:

      - env1: base environment where jupyter-notebook is installed and started from

      - env2: project environment with ipykernel installed
      I manually added kernelspecs for the 2 environments following this guide.



      Everything works fine. sys.executable in 2 kernels show separate, correct paths. But for terminal commands (i.e. !which python), no matter which kernel I'm running in the environment defaults to env1.



      Is there any way to have the notebook automatically change this to the kernel's environment?



      P.S. I already tried installing nb_conda, nb_conda_kernels







      python jupyter-notebook conda






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 7 '18 at 3:52







      Nguyễn Trọng Tín

















      asked Nov 23 '18 at 5:12









      Nguyễn Trọng TínNguyễn Trọng Tín

      8310




      8310
























          1 Answer
          1






          active

          oldest

          votes


















          0














          install nb_conda and nb_conda_kernels into your base.



          conda install nb_conda nb_conda_kernels -n env1


          This should give you the ability to change kernel in jupyter, and use the env2 kernel.






          share|improve this answer
























          • This does not work. In fact I already had these 2 packages from before.

            – Nguyễn Trọng Tín
            Dec 7 '18 at 3:51











          • Can you try listing kernelspecs? jupyter kernelspec list

            – emmet02
            Dec 7 '18 at 9:41











          • python3 /home/ec2-user/miniconda3/envs/airflow3/lib/python3.6/site-p ackages/ipykernel/resources | airflow3 /home/ec2-user/.local/share/jupyter/kernels/airflow3 | data_interface /home/ec2-user/.local/share/jupyter/kernels/data_interface

            – Nguyễn Trọng Tín
            Dec 7 '18 at 9:52













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440940%2fjupyter-notebooks-terminal-command-not-using-correct-conda-environment%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          install nb_conda and nb_conda_kernels into your base.



          conda install nb_conda nb_conda_kernels -n env1


          This should give you the ability to change kernel in jupyter, and use the env2 kernel.






          share|improve this answer
























          • This does not work. In fact I already had these 2 packages from before.

            – Nguyễn Trọng Tín
            Dec 7 '18 at 3:51











          • Can you try listing kernelspecs? jupyter kernelspec list

            – emmet02
            Dec 7 '18 at 9:41











          • python3 /home/ec2-user/miniconda3/envs/airflow3/lib/python3.6/site-p ackages/ipykernel/resources | airflow3 /home/ec2-user/.local/share/jupyter/kernels/airflow3 | data_interface /home/ec2-user/.local/share/jupyter/kernels/data_interface

            – Nguyễn Trọng Tín
            Dec 7 '18 at 9:52


















          0














          install nb_conda and nb_conda_kernels into your base.



          conda install nb_conda nb_conda_kernels -n env1


          This should give you the ability to change kernel in jupyter, and use the env2 kernel.






          share|improve this answer
























          • This does not work. In fact I already had these 2 packages from before.

            – Nguyễn Trọng Tín
            Dec 7 '18 at 3:51











          • Can you try listing kernelspecs? jupyter kernelspec list

            – emmet02
            Dec 7 '18 at 9:41











          • python3 /home/ec2-user/miniconda3/envs/airflow3/lib/python3.6/site-p ackages/ipykernel/resources | airflow3 /home/ec2-user/.local/share/jupyter/kernels/airflow3 | data_interface /home/ec2-user/.local/share/jupyter/kernels/data_interface

            – Nguyễn Trọng Tín
            Dec 7 '18 at 9:52
















          0












          0








          0







          install nb_conda and nb_conda_kernels into your base.



          conda install nb_conda nb_conda_kernels -n env1


          This should give you the ability to change kernel in jupyter, and use the env2 kernel.






          share|improve this answer













          install nb_conda and nb_conda_kernels into your base.



          conda install nb_conda nb_conda_kernels -n env1


          This should give you the ability to change kernel in jupyter, and use the env2 kernel.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 13:52









          emmet02emmet02

          68417




          68417













          • This does not work. In fact I already had these 2 packages from before.

            – Nguyễn Trọng Tín
            Dec 7 '18 at 3:51











          • Can you try listing kernelspecs? jupyter kernelspec list

            – emmet02
            Dec 7 '18 at 9:41











          • python3 /home/ec2-user/miniconda3/envs/airflow3/lib/python3.6/site-p ackages/ipykernel/resources | airflow3 /home/ec2-user/.local/share/jupyter/kernels/airflow3 | data_interface /home/ec2-user/.local/share/jupyter/kernels/data_interface

            – Nguyễn Trọng Tín
            Dec 7 '18 at 9:52





















          • This does not work. In fact I already had these 2 packages from before.

            – Nguyễn Trọng Tín
            Dec 7 '18 at 3:51











          • Can you try listing kernelspecs? jupyter kernelspec list

            – emmet02
            Dec 7 '18 at 9:41











          • python3 /home/ec2-user/miniconda3/envs/airflow3/lib/python3.6/site-p ackages/ipykernel/resources | airflow3 /home/ec2-user/.local/share/jupyter/kernels/airflow3 | data_interface /home/ec2-user/.local/share/jupyter/kernels/data_interface

            – Nguyễn Trọng Tín
            Dec 7 '18 at 9:52



















          This does not work. In fact I already had these 2 packages from before.

          – Nguyễn Trọng Tín
          Dec 7 '18 at 3:51





          This does not work. In fact I already had these 2 packages from before.

          – Nguyễn Trọng Tín
          Dec 7 '18 at 3:51













          Can you try listing kernelspecs? jupyter kernelspec list

          – emmet02
          Dec 7 '18 at 9:41





          Can you try listing kernelspecs? jupyter kernelspec list

          – emmet02
          Dec 7 '18 at 9:41













          python3 /home/ec2-user/miniconda3/envs/airflow3/lib/python3.6/site-p ackages/ipykernel/resources | airflow3 /home/ec2-user/.local/share/jupyter/kernels/airflow3 | data_interface /home/ec2-user/.local/share/jupyter/kernels/data_interface

          – Nguyễn Trọng Tín
          Dec 7 '18 at 9:52







          python3 /home/ec2-user/miniconda3/envs/airflow3/lib/python3.6/site-p ackages/ipykernel/resources | airflow3 /home/ec2-user/.local/share/jupyter/kernels/airflow3 | data_interface /home/ec2-user/.local/share/jupyter/kernels/data_interface

          – Nguyễn Trọng Tín
          Dec 7 '18 at 9:52




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53440940%2fjupyter-notebooks-terminal-command-not-using-correct-conda-environment%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Wiesbaden

          Marschland

          Dieringhausen