如何使用在虚拟环境中工作的jupyter笔记本电脑全新安装Anaconda。视窗

时间:2019-03-27 14:24:05

标签: python jupyter-notebook anaconda

问题:

我在Windows上中断了Anaconda安装。 我已卸载并重新安装了几次。 每次我都有不同的问题。 我的目标很简单:我想使用在Windows虚拟环境中运行的jupyter笔记本电脑完整安装Anaconda。

问题 正确的程序是什么? ?我是错误地卸载和清洁还是安装错误?

我尝试过的事情:

卸载/清洁

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

安装

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

问题:

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

enter image description here

我试图解决

conda install MySQL-python

我运行“ jupyter笔记本”,同样的问题,我无法“在脚本中导入MySQL” 我在外壳中输入python,然后可以导入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
>>> 

因此它可以使用外壳程序工作,但不适用于jupyter笔记本

我尝试过,但这是一个死胡同:

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

我尝试过:

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'

1 个答案:

答案 0 :(得分:0)

这很适合我。

卸载/清洁

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

安装

我在https://repo.anaconda.com/archive/Anaconda2-2018.12-Windows-x86_64.exe上下载了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

我确实更新了所有内容

conda update --all

我创建了一个名为mynewenv的新环境。 使用python = 2并安装了以下软件包:MySQL-python pandas numpy matplotlib scikit-learn

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

然后,我们安装ipkernel,并创建一个新内核。 有关https://anbasile.github.io/programming/2017/06/25/jupyter-venv/

的更多信息
pip install ipykernel
ipython kernel install --user --name=mynewenv

这时,您可以启动jupyter,创建一个新笔记本,然后选择环境中的内核。

enter image description here