在win10上安装Anaconda并运行python程序

版权声明:如需转载或引用,请注明出处。 https://blog.csdn.net/weixin_39278265/article/details/82940274

前言

本文旨在介绍在win10上安装anaconda。

1 下载&安装

1.1 下载

下载地址:https://www.anaconda.com/download/


在这里插入图片描述
下载界面,我选择的是64位python 3.7版本

64位安装包:Anaconda3-5.3.0-Windows-x86_64
32位安装包:Anaconda3-5.3.0-Windows-x86
学到了,这就是64和32的命名区别,前者多一个64.

1.2 安装

接下来自然是默认安装:


在这里插入图片描述
当然,我修改了软件安装路径。

注意,官方提示http://docs.anaconda.com/anaconda/install/windows/:

NOTE: Install Anaconda to a directory path that does not contain spaces or unicode characters.
NOTE: Do not install as Administrator unless admin privileges are required.

即:1)不要把anaconda装在空格或者unicode字符的路径上(我理解的是有空格或者中文字符的路径吧)
2)不要 install as Administrator

此外,在安装过程中,anaconda并不推荐自动设置环境变量,原话解释是:may cause problems requiring you to uninstall and reinstall Anaconda.我也暂不深究了。
这里贴一下官方解释:

We recommend not adding Anaconda to the PATH environment variable, since this can interfere with other software. Instead, use Anaconda software by opening Anaconda Navigator or the Anaconda Prompt from the Start Menu.

.


在这里插入图片描述

整个安装时间还挺长。十多分钟至少。
中间有个visual studio code的安利,我拒绝了:


在这里插入图片描述
这个安利暂时不吃,感觉没必要。现在用不到

1.3 如何安装anaconda之前版本?

根据 http://docs.anaconda.com/anaconda/faq/#how-do-i-get-anaconda-with-python-3-5-or-3-6的指导,

You can download previous versions of Anaconda from the Anaconda installer archive.

anaconda之前版本都在这儿: https://repo.anaconda.com/archive/

1.4 anaconda太大了,还可以安装miniconda

参考:http://docs.anaconda.com/anaconda/install/

TIP: If you don’t want the hundreds of packages included with Anaconda, you can install Miniconda, a mini version of Anaconda that includes just conda, its dependencies and Python.

miniconda五脏俱全,包含:conda,conda的依赖,python。

官方:https://conda.io/docs/user-guide/install/index.html

The fastest way to obtain conda is to install Miniconda, a mini version of Anaconda that includes only conda and its dependencies. If you prefer to have conda plus over 720 open source packages, install Anaconda.

miniconda下载地址:https://conda.io/miniconda.html

1.5 如果出现 “Setup was unable to create the directory”, “Access is denied”, or “Error opening file for writing” 这类问题怎么办

参考:http://docs.anaconda.com/anaconda/user-guide/troubleshooting/#distro-troubleshooting-favorites-folder

Windows permission errors when installing from Favorites folder
Cause
The Windows Favorites folder has unusual permissions and may cause permission errors with installers of any software. If you try launching the installer from the Favorites folder you may see errors such as “Setup was unable to create the directory”, “Access is denied”, or “Error opening file for writing”.
Solution
Move the installer to a different folder and run the installer from the new folder.

多半是anaconda的安装目录是 Windows Favorites folder[1],这个favorite folder具体是什么我也不懂,可以参考[1]。这时候,anaconda是没有写文件的权限的,所以最好换一个目录安装。

2 在anaconda上运行第一个程序

2.1 在anaconda navigator中运行

先打开Anaconda Navigator:


在这里插入图片描述

然后进入主界面,点击spyder的launch就可以啦


在这里插入图片描述

然后F5run就完事了。

2.1 在anaconda prompt中运行

也可以在anaconda prompt中运行,还是在windows开始菜单中找到anaconda prompt,打开,输入print("Hello Anaconda!")


在这里插入图片描述

输入ctrl+z即可退出,其实也可以输入exit(0)。就是辣么神奇。虽然官方说不行。

On Windows press CTRL-Z and press Enter. On macOS or Linux type exit() and press Enter.

参考文献

[1] Where is the Favorites folder in Windows 10 so i can back it up. https://answers.microsoft.com/en-us/windows/forum/windows_10-files/where-is-the-favorites-folder-in-windows-10-so-i/6930cec2-8f2d-4e07-bf99-46c0974b69f0

猜你喜欢

转载自blog.csdn.net/weixin_39278265/article/details/82940274
今日推荐