After pip install jupyter within a virtualenv, the Python 3 kernel is hardcoded for that virtualenv's python. How to fix? - ipython

I switch to any other virtualenv and do a "pip install jupyter", when I run the notebook the Python 3 kernel is hardcoded to point to the python of the initial virtualenv that jupyter was installed in.
Is there a way to fix this?

Related

Not able to install feature -Engine Module

I am trying to install feature-engine module on anaconda
this is the error i am getting
Package is not available from current channels
repo.anaconda win 64 , noarch etc.
Can you please help me with the problem?
Thanks,
RD
to install from anaconda:
conda install -c conda-forge feature_engine
I believe that feature-engine is not available through anaconda channels for installation with conda install. I was able to install it via pip. Here is how I did it (in Windows):
open a CMD and run conda activate <<VIRTUALENV>>. This is the environment you create for your project. If you have not created one, then use base, the default one.
cd to the location of your pip installation within that activated conda Virtual environment (mine was within my user folder in \AppData\Local\Continuum\anaconda3\envs\<<VIRTUALENV>>\Scripts).
in there, run pip install feature-engine
you should now be able to see it listed under pip freeze or pip list, but not under conda list.
Finally, go to your code location and run the code. remember to activate that same <> each time you open a new CMD to run it.
Hope it helps.
If you are using Jupyter Notebooks, it might be the case that your Jupyter Notebook is not actually running the kernel in your (activated!) Anaconda environment (via this answer), but the generic Python3 kernel that only can import packages from your global Anaconda environment.
You can check for this by importing a package that is installed in your global environment (e.g., pandas), while running a notebook:
import pandas
pandas.__file__
If you see something likes this (on Windows), you are indeed running the wrong kernel (as you would expect the packages to be loaded from the activated environments):
'C:\\Users\\<user>\\Anaconda3\\lib\\site-packages\\pandas\\__init__.py'
Therefore, in your Anaconda Prompt, you have to create a new kernel within ipykernel (assuming cenv is your environment of interest):
$ conda activate cenv # . ./cenv/bin/activate in case of virtualenv
(cenv)$ conda install ipykernel
(cenv)$ ipython kernel install --user --name=<any_name_for_kernel>
(cenv)$ jupyter notebook
Now, in the restarted Jupyter Notebook you can change the kernel via the menu: Kernel > Change kernel > <any_name_for_kernel>
Importing the same package, like pandas, should show the following file path:
'C:\\Users\\<user>\\Anaconda3\\envs\\<cenv>\\lib\\site-packages\\pandas\\__init__.py'
and you should be able to import any package installed in that Anaconda environment.

jupyter executables not accessible after pip install on ubuntu

I have installed jupyter - but to double check ran the install again:
pip install jupyter
..
Requirement already satisfied (use --upgrade to upgrade): jupyter in ./.local/lib/python2.7/site-packages
However there is no jupyter (or jupyter-notebook etc.) on the $PATH or anywhere under /usr
find /usr -name jupyter
Where is it installed? I am on ubuntu 16.0.4
Maybe I'm wrong but is your
PYTHONPATH
correct?
Because it should be installed there :
/usr/local/lib/python2.7/dist-packages
or
/usr/lib/python2.7/dist-packages
And if really you struggle with system based python and Jupyter, I think you should install Anaconda instead.
It's the most used, production ready, compartimented python environment.
And it has jupyter built-in.
To finish my argumentation, it's the recommanded way to install Jupyter.

add existing anaconda to jupyter notebook mac

I've installed anaconda2 and anaconda3 from official website
and now have 2 folders:
user/anaconda with anaconda2
user/anaconda3/anaconda with anacaonda3
the default path for python is set for anaconda 2:
MacBook-Air:anaconda zelenov$ which python
/Users/zelenov/anaconda/bin/python
but when I run jupyter notebook I can create only python 3 notebook
how can I add my python2 environment?
I tried this, but it didn't help:
python2 -m pip install ipykernel
python2 -m ipykernel install --user
Thanks in advance for any help!
Choose one Anaconda distribution, not both. I suggest uninstalling one of those distributions, e.g. Python 2. Then create an environment within your Python 3 distribution:
> conda create --name py27 python=2.7
Once the environment is created, you need to enter it, install ipykernel, then exit the environment once completed.
> source activate py27
> conda install ipykernel
> source deactivate
Note source can be omitted for Windows users. As of Anaconda 4.2, installing ipykernel is sufficient for creating a jupyter kernel automatically. Start jupyter:
> jupyter notebook
You should see a dropdown menu in the dashboard with the name of the py27 kernel installed. For more information on installing Python kernels, see Jupyter documentation.

Add python 2.7 to ipython notebook (default python3)

I am having a really hard time adding python 2.7 as a kernel to my iphyton notebook. I have anaconda installed with a python environment called "python2." I can navigate to the environment folder and launch ipython (using python 2.7) in the script folder.
I have tried ipython kernelspec install-self using iphython.exe, however, it seems like ipython is not even a command in that window.
I tried it again in anaconda command window and it just install python3. Please help with precise steps.
Ok I got it. I had to:
Change my python.exe under envs to python2.exe. I also change pythonw to pythonw2.
Added Anacoda\envs\python2 folder that includes python2.exe and scripts to path variable
Then ran this command in Anaconda command window: python2 -m IPython kernelspec install-self
Then ipython kernelspec list to verify

Created an Anaconda python3 environment but it still loads ipython 2.7.6

So I installed Anaconda on my Ubuntu linux 12.04LTS x64 box. It seems to work fine except for this. So I created a conda environment using the
conda create -n py33dev python=3 anaconda
When I try to run the ipython shell, I would expect to get the Ipython3 shell and notebook. However, it still loads the ipython 2.7.6 shell. I tried using the ipython3 command, but it will then load an ipython3 shell from my computer and not from Anaconda.
I tried to install ipython3 to the Anaconda environment using
pip install ipython3
and
conda install ipython3
However, when I do this I just get a message saying "No packages found matching: ipython3"
So I am not sure why Anaconda runs fine with python2 but not with python3--even though Continuum indicates it is python3 ready. Am I missing a step anywhere? Does anyone know how to solve this?
Did you remember to do "source activate py33dev"?