Ludo Schmidt
Ludo Schmidt

Reputation: 1403

How to make a clean fresh install of Anaconda with jupyter notebook working on a virtual environement. Windows

Problem:

I broke my Anaconda installation on Windows. I have uninstalled and reinstalled several times. And each time I have a differents problems. My goal is simple: I want to o make a clean install of Anaconda with jupyter notebook working on a virtual environement on Windows.

The question What is the correct procedure? Am I wrong uninstalling and cleaning, or am I wrong installing?

What I tryed:

uninstalling/cleaning

conda install anaconda-clean
anaconda-clean --yes
Then uninstall python2(anaconda)
Then delete some anaconda folder manualy. .anaconda .conda .ipython .jupyter
Then CCleaner, clean registry
Then reboot

installing

I downolad https://repo.anaconda.com/archive/Anaconda2-2018.12-Windows-x86_64.exe on https://www.anaconda.com/distribution/#windows
I install everithings as default. Except that I add Anaconda to the PATH environment variable, since I want to use environnements. 
I do:
conda create -n mynewenv python=2 MySQL-python pandas numpy matplotlib scikit-learn
activate mynewenv

problem:

I run "jupyter notebook" ( mynewenv still activated )
I can't "import MySQL in my scripts" 

enter image description here

I tryed to fix

conda install MySQL-python

I run "jupyter notebook", same issue I can't "import MySQL in my script" I type python in the shell and there I can import MySQLdb:

(mynewenv) C:\Users\me>python
Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 15:42:17) [MSC v.1500 64 b
it (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>> 

So it work using the shell but not with jupyter notebook

I tryed this but it's a dead end:

conda install nb_conda_kernels # it should make me able to switch kernel but then can't use jupyter anymore

I tryed:

conda install jupyter #when mynew env still activated
the idea is to have jupyter installed on the new environnement.( why not )

I get this when installing
Executing transaction: \ DEBUG menuinst_win32:__init__(196): Menu: name: 'Anacon
da${PY_VER} ${PLATFORM}', prefix: 'C:\Users\Y\Anaconda2\envs\mynewenv', env_name
: 'mynewenv', mode: 'user', used_mode: 'user'
DEBUG menuinst_win32:create(320): Shortcut cmd is C:\Users\Y\Anaconda2\python.ex
e, args are [u'C:\\Users\\Y\\Anaconda2\\cwp.py', u'C:\\Users\\Y\\Anaconda2\\envs
\\mynewenv', u'C:\\Users\\Y\\Anaconda2\\envs\\mynewenv\\python.exe', u'C:\\Users
\\Y\\Anaconda2\\envs\\mynewenv\\Scripts\\jupyter-notebook-script.py', u'"%USERPR
OFILE%/"']
done

Then I run 'jupyter notebook'. It run for 5 second then stop. ( no error messages)

I run it again, I get:
(mynewenv) C:\Users\Y>jupyter notebook
Unable to create process using 'C:\Users\Y\Anaconda2\envs\mynewenv\python.exe C:\Users\Y\Anaconda2\envs\mynewenv\Scripts\jupyter-script.py notebook'

Upvotes: 2

Views: 10601

Answers (1)

Ludo Schmidt
Ludo Schmidt

Reputation: 1403

This finnaly worked for me.

Uninstalling/cleaning

conda install anaconda-clean
anaconda-clean --yes
Then uninstall python2(anaconda)
Then delete some anaconda folder manually. .anaconda .conda .ipython .jupyter
Then CCleaner, clean registry
Then reboot

Installing

I download https://repo.anaconda.com/archive/Anaconda2-2018.12-Windows-x86_64.exe on https://www.anaconda.com/distribution/#windows

I install everything as default. 
Except that I add Anaconda to the PATH environment variable, since I want to use environments. more info: https://stackoverflow.com/questions/52664293/why-or-why-not-add-anaconda-to-path

I do update everything

conda update --all

I create a new environment, with name mynewenv. With python=2 and these package installed: MySQL-python pandas numpy matplotlib scikit-learn

conda create -n mynewenv python=2 MySQL-python pandas numpy matplotlib scikit-learn
conda activate mynewenv

Then we install ipkernel, and create a new kernel. More info on https://anbasile.github.io/programming/2017/06/25/jupyter-venv/

pip install ipykernel
ipython kernel install --user --name=mynewenv

At this point, you can start jupyter, create a new notebook and select the kernel that lives inside your environment.

enter image description here

Upvotes: 1

Related Questions