标签归档:anaconda

Anaconda vs. EPD Enthought vs.手动安装Python [关闭]

问题:Anaconda vs. EPD Enthought vs.手动安装Python [关闭]

与手动安装相比,各种Python捆绑包(EPD / Anaconda)有哪些相对优点/缺点?

我已经安装了EPD Academic,但没有任何问题。它提供了我认为我将永远需要的更多软件包,并且使用enpkg enstaller进行更新非常容易。EPD学术许可证需要每年更新一次,而免费版本的更新并不那么容易。

目前,我实际上只使用了一些软件包,例如PandasNumPySciPymatplotlibIPythonStatsmodels及其各自的依赖项。

对于这种有限的使用,我最好手动安装,pip install --upgrade 'package'还是捆绑包提供了除此以外的其他功能?

What are the relative merits / downsides of various Python bundles (EPD / Anaconda) vs. a manual install?

I have installed EPD academic, and I have no issues with it. It provides more packages that I think I will ever need, and it is very easy to update using enpkg enstaller. The EPD academic licence requires yearly renewal however and the free version does not do updates as easily.

At the moment I really only use a handful of packages such as Pandas, NumPy, SciPy, matplotlib, IPython, Statsmodels and their respective dependencies.

For such limited use am I better off with manual install and pip install --upgrade 'package' or do the bundles offer anything over and above this?


回答 0

2015年更新:如今,我总是推荐水蟒。它包括许多用于科学计算,数据科学,Web开发等的Python程序包。它还提供了一个高级的环境工具conda,该工具可以轻松地在环境之间切换,甚至在Python 2和3之间切换。它也很快得到了更新。当发布新版本的软件包时,您可以conda update packagename进行更新。

以下为原始答案

在Windows上,复杂的是编译数学软件包,因此,我认为仅当您仅对Python而不是其他软件包感兴趣时,手动安装才是可行的选择。

因此最好选择EPD(现为Canopy)或Anaconda。

Anaconda大约有270个软件包,其中包括对于大多数科学应用程序和数据分析而言最重要的软件包,即NumPySciPyPandasIPythonmatplotlibScikit-learn。因此,如果这对您来说足够,我会选择Anaconda。

相反,如果您对其他软件包感兴趣,并且如果您使用任何Enthought软件包(例如Chaco对于实时数据可视化非常有用),则EPD / Canopy可能是一个更好的选择。学术版在基本安装中包含大量软件包,在存储库中包含更多软件包。Anaconda还包括Chaco。

Update 2015: Nowadays I always recommend Anaconda. It includes lots of Python packages for scientific computing, data science, web development, etc. It also provides a superior environment tool, conda, which allows to easily switch between environments, even between Python 2 and 3. It is also updated very quickly as soon as a new version of a package is released, and you can just do conda update packagename to update it.

Original answer below:

On Windows, what is complicated is to compile the math packages, so I think a manual install is a viable option only if you are interested only in Python, without other packages.

Therefore better chose either EPD (now Canopy) or Anaconda.

Anaconda has around 270 packages, including the most important for most scientific applications and data analysis, that is, NumPy, SciPy, Pandas, IPython, matplotlib, Scikit-learn. So if this is enough for you, I would choose Anaconda.

Instead, if you are interested in other packages, and even more if you use any of the Enthought packages (Chaco for example is very useful for realtime data visualization), then EPD/Canopy is probably a better choice. The Academic version has a larger number of packages in the base install, and many more in the repository. Anaconda also includes Chaco.


回答 1

去年,我尝试了各种Windows发行版,试图为我的工作环境找到一个合适的版本(在代理之后,但无法访问代理配置)。

这是我的经验反馈:

EPD / Canopy: 我们拥有EPD许可证,但是它很旧,并且由于代理服务器情况怪异而无法更新。为了添加一些软件包(例如xlrd / xlwt的最新版本),我从源代码进行了编译。要更新SciPyNumPy,我使用了http://www.lfd.uci.edu/~gohlke/pythonlibs/中的预编译安装程序,但有时会破坏兼容性。我喜欢拥有完全配置的Py2exeCython,它开箱即用。

过了一会儿,我尝试安装Canopy的免费版本,但是它缺少Cython和py2exe以及一些我需要的特定高级软件包,因此我从未真正使用过它。我的一些同事购买了完整的Canopy许可证,但是我们仍然不确定他们将如何更新…

Python(x,y): 不想在许可证上挣扎,我在家安装了Python(x,y)。我现在注意到的唯一缺点是标准安装要求您选择所需的软件包。这既有好处也有坏处,因为我不确定我的客户端将具有与安装时完全相同的配置。(可以在Python(x,y)中安装Enthought工具套件。)使用Python(x,y)一段时间后,我只是注意到我安装了32位版本。尽管在他们的网站上不清楚,但截至2015年7月,他们似乎还没有64位版本。我打算将其卸载并获得64位版本。

Anaconda: 当我第一次写这篇文章时,Anaconda似乎还没有足够的软件包。几年后,它似乎好多了,我将尝试一下!

手册: 为了避免与我们的旧EPD版本存在版本兼容性问题,我最终使用了手动安装Python,并从上面链接的LFD网站添加了其他软件包。效果很好,但我仍然向需要高级软件包(例如GDALPyFITS)的新用户建议Canopy 。

摘要:如果您要购买Canopy,请获取完整的许可证(学术版或购买的)。否则,使用Python(x,y),结果将相同。

在Ubuntu上: 不需要分发。这些都是相对较新的(可以容忍+/- 6个月)并已预编译。您只需要执行sudo apt-get install python python-scipy就可以了!也有最高级的软件包。

I have tried various Windows distributions in the last year, trying to find one sutable for my work environment (behind a proxy, but without access to proxy configuration).

Here is my feedback from experience:

EPD/Canopy: We had a license of EPD, but it was old and we were unable to update becasue of the weird proxy situation. In order to add some packages (such as recent version of xlrd/xlwt), I compiled from source. To update SciPy and NumPy, I used the precompiled installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/, but it would sometimes screw up compatibility. I loved having a fully configured Py2exe and Cython, and it simply worked out of the box.

After a while, I tried installing the free version of Canopy, but it lacks Cython and py2exe and some specific advanced packaged I needed, so I never really used it. Some of my colleagues bought the full Canopy license, but we’re still not sure how they’re going to update…

Python(x,y): Not wanting to struggle with licenses, I installed Python(x,y) at home. The only downside I noticed right now is that the standard installation requires you to select which packages you want. It’s both a good and a bad point, because I can’t be sure that my clients will have the exact same configuration as I do when I install. (The Enthought tool suite can be installed in Python(x,y).) After using Python(x,y) for a while, I just noticed I installed the 32 bit version. Although it is not clear on their website, it seems they don’t have a 64 bit version as of July 2015. I’m going to uninstall it and get a 64 bit distribution.

Anaconda: When I first wrote this, Anaconda didn’t seem to have enough packages yet. A couple of years later, it seems much better, I’m going to give it a try!

Manual: In order to avoid version compatibility issues with our old EPD version, I ended up using manual Python installation and adding additional packages from the LFD website linked above. It works great, but I would still suggest Canopy to a new user who requires advanced packages (like GDAL or PyFITS).

Summary: If you go for Canopy, get the full licence (Academic or purchased). Else, go with Python(x,y), it will end up being the same.

On Ubuntu: No need for a distribution. It’s all relatively recent (+/- 6 months is tolerable) and pre-compiled. You just need to execute sudo apt-get install python python-scipy and it’s there! Most advanced packages are there as well.


回答 2

其他答案很好地覆盖了地面,因此我只想谈谈一个尚未提及的特定方面。它可能是相当利基的,但是对于Linux系统下的某些人来说,它可能会制造或破坏Anaconda或Canopy:

Anaconda Python版本使用UCS4 Unicode模式,而Enthought Canopy使用UCS2。

实际上,这意味着如果您依赖任何因某种原因而无法自行编译的扩展(例如,预编译的专有库),并且如果它们不是为使用相同模式的Python版本构建的,则可能会更快或以后遇到类似于的错误undefined symbol: PyUnicodeUCS4_AsUTF8String

根据PEP 0513,UCS4当前似乎更为流行和推荐。同样,整个UCS兼容性问题似乎仅影响2.x和<3.3版本。

The other answers cover the ground quite nicely, so I just want to remark on one particular aspect that nobody has mentioned yet. It is probably fairly niche, but it may potentially make or break Anaconda or Canopy for some people under Linux systems:

Anaconda Python builds use the UCS4 Unicode mode, whereas Enthought Canopy uses UCS2.

What this means in practical terms is that if you rely on any extensions which you cannot compile yourself for whatever reason (e.g. pre-compiled proprietary libraries), if they happen not to be built for a Python version with the same mode, you may sooner or later run into errors that look something like undefined symbol: PyUnicodeUCS4_AsUTF8String.

According to PEP 0513, UCS4 seems to currently be more popular and recommended. Also, the whole UCS compatibility issues seem to only affect 2.x and < 3.3 versions.


回答 3

我使用Anaconda已有多年,并且非常喜欢它。不幸的是,如果没有企业版,则无法使用IPython Notebook(现在为Jupyter)。

我想在教室里使用Jupyter笔记本,所以我改用Canopy。安装我们需要的所有软件包似乎很容易。诚然,我们还没有对它们全部进行测试。

I used Anaconda for years and liked it quite a bit. Unfortunately, IPython Notebook (now Jupyter) is unavailable without the enterprise edition.

I want to use Jupyter notebooks in the classroom, so I switched to Canopy. It seems easy enough to install all of the packages we need. Admittedly, we haven’t tested them all.


Anaconda与Python有何关系?

问题:Anaconda与Python有何关系?

我是一个初学者,我想学习计算机编程。因此,到目前为止,我已经开始自己学习Python,并掌握了有关C和Fortran编程的知识。

现在,我已经安装了Python 3.6.0版,并且一直在努力寻找适合该版本的Python学习文字。甚至在线讲座系列也要求版本2.7和2.5。

现在,我已经有了一本书,但是,该书在版本2中进行了编码,并试图在版本3中使其尽可能接近(根据作者);作者建议“下载Windows版Anaconda”以安装Python。

所以,我的问题是:这是什么“ Anaconda”?我看到这是一个开放的数据科学平台。这是什么意思?是某些编辑器还是诸如Pycharm,IDLE之类的东西?

另外,我从Python.org下载了适用于Windows的Python(我现在正在使用的Python),而我不需要安装任何“开放数据科学平台”。那么这是怎么回事?

请用简单的语言解释。我对这些没有太多的了解。

I am a beginner and I want to learn computer programming. So, for now, I have started learning Python by myself with some knowledge about programming in C and Fortran.

Now, I have installed Python version 3.6.0 and I have struggled finding a suitable text for learning Python in this version. Even the online lecture series ask for versions 2.7 and 2.5 .

Now that I have got a book which, however, makes codes in version 2 and tries to make it as close as possible in version 3 (according to the author); the author recommends “downloading Anaconda for Windows” for installing Python.

So, my question is: What is this ‘Anaconda’? I saw that it was some open data science platform. What does it mean? Is it some editor or something like Pycharm, IDLE or something?

Also, I downloaded my Python (the one that I am using right now) for Windows from Python.org and I didn’t need to install any “open data science platform”. So what is this happening?

Please explain in easy language. I don’t have too much knowledge about these.


回答 0

Anaconda是python和R 发行版。它旨在“开箱即用”地提供数据科学所需的一切(Python方面)。

这包括:

  • 核心Python语言
  • 100多个Python“软件包”(库)
  • Spyder(IDE /编辑器-如PyCharm)和Jupyter
  • conda,Anaconda自己的软件包管理器,用于更新Anaconda和软件包

您的类可能已经推荐了这些额外功能,但是如果您不需要它们,并且可以使用香草Python也可以。

了解更多信息:https : //www.anaconda.com/distribution/

Anaconda is a python and R distribution. It aims to provide everything you need (Python-wise) for data science “out of the box”.

It includes:

  • The core Python language
  • 100+ Python “packages” (libraries)
  • Spyder (IDE/editor – like PyCharm) and Jupyter
  • conda, Anaconda’s own package manager, used for updating Anaconda and packages

Your course may have recommended it as it comes with these extras but if you don’t need them and are getting on fine with vanilla Python that’s OK too.

Learn more: https://www.anaconda.com/distribution/


回答 1

Anaconda是一个Python发行版,可轻松以灵活的方式在Windows或Linux机器上安装Python以及其最常用的第三方库。

我在Windows和Linux上的使用经验都非常积极。它非常完整,可以避免从源代码构建所需的库时出现问题,而这些问题经常通过诸如pip之类的工具一一安装这些库。

顺便说一句:从3.5或3.6开始非常明智,因为2.7即将接近其生命周期,尽管许多应用程序仍依赖它。

至于教程:Python自己的文档非常适合学习该语言。

https://docs.python.org/3/tutorial/

Anaconda is a Python distribution that makes it easy to install Python plus a number of its most often used 3rd party libraries in a flexible way on a Windows or Linux machine.

My experiences with it are very positive, both on Windows and Linux. It is quite complete and avoids problems in building libraries that you need from source code, that frequently plague one by one installations of those libraries by tools like pip.

By the way: It’s very wise to start with 3.5 or 3.6 since 2.7 is approaching the end of its lifecycle, though many applications still depend on it.

As for tutorials: Pythons own docs are quite suitable for learning the language.

https://docs.python.org/3/tutorial/


回答 2

Anaconda是基于Python的数据处理和科学计算平台。它内置了许多非常有用的第三方库。安装Anaconda等效于自动安装Python和一些常用的库,例如Numpy,Pandas,Scrip和Matplotlib,因此,它比常规的Python安装容易得多。如果您没有安装Anaconda,而是仅从python.org安装Python,则还需要使用pip逐一安装各种库。这很痛苦,您需要考虑兼容性,因此强烈建议直接安装Anaconda。

Anaconda is a Python-based data processing and scientific computing platform. It has built in many very useful third-party libraries. Installing Anaconda is equivalent to automatically installing Python and some commonly used libraries such as Numpy, Pandas, Scrip, and Matplotlib, so it makes the installation so much easier than regular Python installation. If you don’t install Anaconda, but instead only install Python from python.org, you also need to use pip to install various libraries one by one. It is painful and you need to consider compatibility, thus it is highly recommended to directly install Anaconda.


pip抛出TypeError:尝试安装新软件包时parse()得到了意外的关键字参数’transport_encoding’

问题:pip抛出TypeError:尝试安装新软件包时parse()得到了意外的关键字参数’transport_encoding’

我正在使用最新版本的Anaconda3。我刚刚安装了它,我正在尝试下载一些软件包。我正在使用Anaconda Prompt。尝试使用pip做任何事情(包括升级现有软件包)时,我得到以下回溯。

    Exception:
Traceback (most recent call last):
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\commands\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 487, in _prepare_file
    req_to_install, finder)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 428, in _check_skip_installed
    req_to_install, upgrade_allowed)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 811, in get_page
    inst = cls(resp.content, resp.url, resp.headers)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 731, in __init__
    namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'

有任何想法吗?(这个问题只有在我安装了tensorflow之后才开始出现)谢谢。

I am using the latest version of Anaconda3. I just installed it and I am trying to download some packages. I am using the Anaconda Prompt. While trying to use pip to do anything (including upgrading existing packages) I get the following traceback.

    Exception:
Traceback (most recent call last):
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\commands\install.py", line 335, in run
    wb.build(autobuilding=True)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
    self.requirement_set.prepare_files(self.finder)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 487, in _prepare_file
    req_to_install, finder)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 428, in _check_skip_installed
    req_to_install, upgrade_allowed)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 811, in get_page
    inst = cls(resp.content, resp.url, resp.headers)
  File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 731, in __init__
    namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'

Any ideas? (this problem only started after I installed tensorflow) Thanks.


回答 0

我有同样的问题,对我有用的是用conda更新点子:

conda install pip

它将我的点值从9.0.1-py36hadba87b_3更改为9.0.1-py36h226ae91_4,并解决了问题。

I had the same problem and what worked for me was updating pip with conda:

conda install pip

It changed my pip from 9.0.1-py36hadba87b_3 to 9.0.1-py36h226ae91_4 and solved issue.


回答 1

下载https://github.com/html5lib/html5lib-python/tree/master/html5lib并覆盖tensorflow环境“ envs \ tensorflow \ Lib \ site-packages \ html5lib”中html5lib文件夹中的所有文件,那么您应该能够在那之后运行任何“ pip install”命令

download https://github.com/html5lib/html5lib-python/tree/master/html5lib and overwrite all the files within html5lib folder in your tensorflow environment “envs\tensorflow\Lib\site-packages\html5lib” Then you should be able to run any “pip install” commands after that


回答 2

我在最新版本的Anaconda 3上安装keras时遇到了相同的问题(使用pip安装tensorflow 1.3之后),我可以通过使用conda安装keras来解决此问题。 conda install -c conda-forge keras

I ran into the same problem while installing keras (after I installed tensorflow 1.3 using pip) on the latest version of Anaconda 3. I was able to fix the problem by installing keras using conda conda install -c conda-forge keras


回答 3

安装SerpentAI时出现此确切错误。我所做的所有修复工作都activate serpent在conda提示符下运行,然后再次运行命令。不知道它是否适用于您的情况,但它们似乎足够接近。

编辑-如果上述方法无效,请注释掉以下行:

这对我来说非常有效。(这花费了我们社区中一个有用的成员进行了8个小时的调试)

I was getting this exact error installing SerpentAI. All I did to fix it was run activate serpent in conda prompt and then I ran the command again. Not sure if it’s applicable to your situation, but they seem close enough that it might.

EDIT – if the above didn’t work, comment out this line:

That worked perfectly for me. (this took a helpful member of our community 8 hours to debug)


回答 4

这对我有用:

python -m pip install –upgrade张量流

This worked for me:

python -m pip install –upgrade tensorflow


回答 5

pip3 install -U html5lib=="0.9999999"

为我工作

这是github上的html5lib错误

来自:https : //stackoverflow.com/a/39087283

pip3 install -U html5lib=="0.9999999"

worked for me

here’s the html5lib bug on github

from: https://stackoverflow.com/a/39087283


回答 6

这是给我的解决方法:

cd /usr/share/python-wheels/

目录的内容:

-rwxrwxrwx   1 www-data www-data 493905 Jul 22  2015 html5lib-0.999-py2.py3-none-any.whl
-rw-r--r--   1 root     root     112620 Apr  3  2019 html5lib-0.999999999-py2.py3-none-any.whl

跑:

mv html5lib-0.999-py2.py3-none-any.whl html5lib-0.999-py2.py3-none-any.whl.bak

pip3工作正常。正在加载旧的0.999版本。

Here was the fix for me:

cd /usr/share/python-wheels/

Contents of dir:

-rwxrwxrwx   1 www-data www-data 493905 Jul 22  2015 html5lib-0.999-py2.py3-none-any.whl
-rw-r--r--   1 root     root     112620 Apr  3  2019 html5lib-0.999999999-py2.py3-none-any.whl

Run:

mv html5lib-0.999-py2.py3-none-any.whl html5lib-0.999-py2.py3-none-any.whl.bak

pip3 works fine after. Was loading the old 0.999 version.


如何知道Jupyter笔记本中正在运行哪个?

问题:如何知道Jupyter笔记本中正在运行哪个?

我在用于Python编程的浏览器中使用Jupyter笔记本,已经安装了Anaconda(Python 3.5)。但是我很确定Jupyter使用本地python解释器而不是anaconda运行我的python命令。如何更改它并将Anaconda用作解释器?

Ubuntu 16.10-Anaconda3

I use Jupyter notebook in a browser for Python programming, I have installed Anaconda (Python 3.5). But I’m quite sure that Jupyter in running my python commands with the native python interpreter and not with anaconda. How can I change it and use Anaconda as interpreter?

Ubuntu 16.10 — Anaconda3


回答 0

from platform import python_version

print(python_version())

这将为您提供运行脚本的python的确切版本。例如输出:

3.6.5
from platform import python_version

print(python_version())

This will give you the exact version of python running your script. eg output:

3.6.5

回答 1

import sys
sys.executable

会给你翻译。您可以在创建新笔记本时选择所需的解释器。确保您的anaconda解释器的路径已添加到您的路径中(最有可能在bashrc / bash_profile中的某个位置)。

例如,我以前在.bash_profile中有以下行,我是手动添加的:

export PATH="$HOME/anaconda3/bin:$PATH"

编辑:如评论中所述,这不是将anaconda添加到路径的正确方法。引用Anaconda的文档,应在安装后改为使用以下方法conda init

我应该将Anaconda添加到macOS或Linux PATH吗?

我们不建议手动将Anaconda添加到PATH。在安装过程中,系统将询问您“是否希望安装程序通过运行conda init来初始化Anaconda3?” 我们建议“是”。如果输入“ no”,则conda根本不会修改您的Shell脚本。为了在安装过程完成后进行初始化,请先运行source <path to conda>/bin/activate然后再运行conda init

import sys
sys.executable

will give you the interpreter. You can select the interpreter you want when you create a new notebook. Make sure the path to your anaconda interpreter is added to your path (somewhere in your bashrc/bash_profile most likely).

For example I used to have the following line in my .bash_profile, that I added manually :

export PATH="$HOME/anaconda3/bin:$PATH"

EDIT: As mentioned in a comment, this is not the proper way to add anaconda to the path. Quoting Anaconda’s doc, this should be done instead after install, using conda init:

Should I add Anaconda to the macOS or Linux PATH?

We do not recommend adding Anaconda to the PATH manually. During installation, you will be asked “Do you wish the installer to initialize Anaconda3 by running conda init?” We recommend “yes”. If you enter “no”, then conda will not modify your shell scripts at all. In order to initialize after the installation process is done, first run source <path to conda>/bin/activate and then run conda init


回答 2

import sys
print(sys.executable)
print(sys.version)
print(sys.version_info)

见下文:-当我在CONDA venv之外运行JupyterNotebook时的输出

/home/dhankar/anaconda2/bin/python
2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:42:40) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0)
 

当我在使用命令创建的CONDA Venv中运行相同的JupyterNoteBook时看到以下内容-

conda create -n py35 python=3.5 ## Here - py35 , is name of my VENV

在我的Jupyter笔记本中打印:

/home/dhankar/anaconda2/envs/py35/bin/python
3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
sys.version_info(major=3, minor=5, micro=2, releaselevel='final', serial=0)

另外,如果您已经使用不同版本的Python创建了各种VENV,则可以通过从JupyterNotebook菜单中选择KERNEL >> CHANGE KERNEL切换到所需的内核… JupyterNotebookScreencapture

还要在现有的CONDA虚拟环境中安装ipykernel-

http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments

来源-https ://github.com/jupyter/notebook/issues/1524

 $ /path/to/python -m  ipykernel install --help
 usage: ipython-kernel-install [-h] [--user] [--name NAME]
                          [--display-name DISPLAY_NAME]
                          [--profile PROFILE] [--prefix PREFIX]
                          [--sys-prefix]

安装IPython内核规范。

可选参数:-h,–help显示此帮助消息并退出–user为当前用户而不是系统范围内安装–name NAME指定kernelspec的名称。需要同时具有多个IPython内核。–display-name DISPLAY_NAME指定kernelspec的显示名称。当您有多个IPython内核时,这将很有帮助。–profile PROFILE指定要加载的IPython配置文件。这可以用来创建内核的自定义版本。–prefix PREFIX为kernelspec指定安装前缀。需要将其安装到非默认位置,例如conda / virtual-env。–sys-prefix安装到Python的sys.prefix。–prefix =’/ Users / bussonniermatthias / anaconda’的简写。用于conda / virtual-envs。

 import sys
 print(sys.executable)
 print(sys.version)
 print(sys.version_info)

Seen below :- output when i run JupyterNotebook outside a CONDA venv

/home/dhankar/anaconda2/bin/python
2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jul  2 2016, 17:42:40) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
sys.version_info(major=2, minor=7, micro=12, releaselevel='final', serial=0)

Seen below when i run same JupyterNoteBook within a CONDA Venv created with command —

conda create -n py35 python=3.5 ## Here - py35 , is name of my VENV

in my Jupyter Notebook it prints :-

/home/dhankar/anaconda2/envs/py35/bin/python
3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
sys.version_info(major=3, minor=5, micro=2, releaselevel='final', serial=0)

also if you already have various VENV’s created with different versions of Python you switch to the desired Kernel by choosing KERNEL >> CHANGE KERNEL from within the JupyterNotebook menu… JupyterNotebookScreencapture

Also to install ipykernel within an existing CONDA Virtual Environment –

http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments

Source — https://github.com/jupyter/notebook/issues/1524

 $ /path/to/python -m  ipykernel install --help
 usage: ipython-kernel-install [-h] [--user] [--name NAME]
                          [--display-name DISPLAY_NAME]
                          [--profile PROFILE] [--prefix PREFIX]
                          [--sys-prefix]

Install the IPython kernel spec.

optional arguments: -h, –help show this help message and exit –user Install for the current user instead of system-wide –name NAME Specify a name for the kernelspec. This is needed to have multiple IPython kernels at the same time. –display-name DISPLAY_NAME Specify the display name for the kernelspec. This is helpful when you have multiple IPython kernels. –profile PROFILE Specify an IPython profile to load. This can be used to create custom versions of the kernel. –prefix PREFIX Specify an install prefix for the kernelspec. This is needed to install into a non-default location, such as a conda/virtual-env. –sys-prefix Install to Python’s sys.prefix. Shorthand for –prefix=’/Users/bussonniermatthias/anaconda’. For use in conda/virtual-envs.


回答 3

假设您的后端系统错误,则可以kernel通过kernel.jsonkernelsjupyter数据路径的文件夹中创建新的或编辑现有的后端来更改后端jupyter --paths。您可以有多个内核(R,Python2,Python3(+ virtualenvs),Haskell),例如,可以创建一个Anaconda特定的内核:

$ <anaconda-path>/bin/python3 -m ipykernel install --user --name anaconda --display-name "Anaconda"

应该创建一个新内核:

<jupyter-data-dir>/kernels/anaconda/kernel.json

{
    "argv": [ "<anaconda-path>/bin/python3", "-m", "ipykernel", "-f", "{connection_file}" ],
    "display_name": "Anaconda",
    "language": "python"
}

您需要确保ipykernel在anaconda发行版中安装了软件包。

这样,您就可以在内核之间切换,并使用不同的内核使用不同的笔记本。

Assuming you have the wrong backend system you can change the backend kernel by creating a new or editing the existing kernel.json in the kernels folder of your jupyter data path jupyter --paths. You can have multiple kernels (R, Python2, Python3 (+virtualenvs), Haskell), e.g. you can create an Anaconda specific kernel:

$ <anaconda-path>/bin/python3 -m ipykernel install --user --name anaconda --display-name "Anaconda"

Should create a new kernel:

<jupyter-data-dir>/kernels/anaconda/kernel.json

{
    "argv": [ "<anaconda-path>/bin/python3", "-m", "ipykernel", "-f", "{connection_file}" ],
    "display_name": "Anaconda",
    "language": "python"
}

You need to ensure ipykernel package is installed in the anaconda distribution.

This way you can just switch between kernels and have different notebooks using different kernels.


回答 4

为Jupyter Notebook创建虚拟环境

最小的Python安装是

sudo apt install python3.7 python3.7-venv python3.7-minimal python3.7-distutils python3.7-dev python3.7-gdbm python3-gdbm-dbg python3-pip

然后您可以创建和使用环境

/usr/bin/python3.7 -m venv test
cd test
source test/bin/activate
pip install jupyter matplotlib seaborn numpy pandas scipy
# install other packages you need with pip/apt
jupyter notebook
deactivate

您可以使用以下命令为Jupyter创建内核

ipython3 kernel install --user --name=test

Creating a virtual environment for Jupyter Notebooks

A minimal Python install is

sudo apt install python3.7 python3.7-venv python3.7-minimal python3.7-distutils python3.7-dev python3.7-gdbm python3-gdbm-dbg python3-pip

Then you can create and use the environment

/usr/bin/python3.7 -m venv test
cd test
source test/bin/activate
pip install jupyter matplotlib seaborn numpy pandas scipy
# install other packages you need with pip/apt
jupyter notebook
deactivate

You can make a kernel for Jupyter with

ipython3 kernel install --user --name=test

结合conda environment.yml和pip requirements.txt

问题:结合conda environment.yml和pip requirements.txt

我在conda环境下工作,还需要一些pip包,例如〜gohlke的预编译轮。

目前,我有两个文件: environment.yml对于conda与:

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda

requirements.txt用于PIP可以上述环境康达激活后使用:

# run: pip install -i requirements.txt
docx
gooey
http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

是否可以将它们合并到一个文件中(用于conda)?

I work with conda environments and need some pip packages as well, e.g. pre-compiled wheels from ~gohlke.

At the moment I have two files: environment.yml for conda with:

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda

and requirements.txt for pip which can be used after activating above conda environment:

# run: pip install -i requirements.txt
docx
gooey
http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

Is there a possibility to combine them in one file (for conda)?


回答 0

点依赖可以包含在这样的environment.yml文件中(docs):

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  # works for regular pip packages
  - docx
  - gooey
  # and for wheels
  - http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

它也适用.whl于同一目录中的文件(请参阅Dengar的answer)以及常见的pip包。

Pip dependencies can be included in the environment.yml file like this (docs):

# run: conda env create --file environment.yml
name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  # works for regular pip packages
  - docx
  - gooey
  # and for wheels
  - http://www.lfd.uci.edu/~gohlke/pythonlibs/bofhrmxk/opencv_python-3.1.0-cp35-none-win_amd64.whl

It also works for .whl files in the same directory (see Dengar’s answer) as well as with common pip packages.


回答 1

也可以requirements.txt直接在YAML中使用。例如,

name: test-env
dependencies:
  - python>=3.5
  - anaconda
  - pip
  - pip:
    - -r file:requirements.txt

基本上,您可以使用的任何选项都可以pip install在YAML中运行。有关其他功能的展示,请参见高级点子示例

One can also use the requirements.txt directly in the YAML. For example,

name: test-env
dependencies:
  - python>=3.5
  - anaconda
  - pip
  - pip:
    - -r file:requirements.txt

Basically, any option you can run with pip install you can run in a YAML. See the Advanced Pip Example for a showcase of other capabilities.


回答 2

只是想补充一点,在目录中添加轮子也可以。使用整个URL时出现此错误:

HTTP error 404 while getting http://www.lfd.uci.edu/~gohlke/pythonlibs/f9r7rmd8/opencv_python-3.1.0-cp35-none-win_amd64.whl

最终下载了转轮,并将其保存到yml文件所在的目录中。

name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  - opencv_python-3.1.0-cp35-none-win_amd64.whl

Just want to add that adding a wheel in the directory also works. I was getting this error when using the entire URL:

HTTP error 404 while getting http://www.lfd.uci.edu/~gohlke/pythonlibs/f9r7rmd8/opencv_python-3.1.0-cp35-none-win_amd64.whl

Ended up downloading the wheel and saving it into the same directory as the yml file.

name: test-env
dependencies:
- python>=3.5
- anaconda
- pip
- pip:
  - opencv_python-3.1.0-cp35-none-win_amd64.whl

Windows 10无法识别Conda命令

问题:Windows 10无法识别Conda命令

我按照以下说明在Windows 10上安装了Anaconda 4.4.0(Python 3.6版本):https : //www.continuum.io/downloads。但是,当我打开命令提示符窗口并尝试编写时

conda list

我得到了

无法识别’conda’命令…

错误。

我试着跑

set PATH=%PATH%;C:\Users\Alex\Anaconda3

但这没有帮助。我还读到我可能需要编辑.bashrc文件,但是我不知道如何访问该文件以及如何编辑它。

I installed Anaconda 4.4.0 (Python 3.6 version) on Windows 10 by following the instructions here: https://www.continuum.io/downloads. However, when I open the Command prompt window and try to write

conda list

I get the

‘conda’ command is not recognized…

error.

I tried to run

set PATH=%PATH%;C:\Users\Alex\Anaconda3

but it didn’t help. I also read that I might need to edit my .bashrc file, but I don’t know how to access this file, and how I should edit it.


回答 0

在Windows中,您必须将路径设置为将Anaconda3安装到的位置。

对我来说,我将anaconda3安装到中C:\Anaconda3。因此,您需要在路径变量中添加C:\Anaconda3C:\Anaconda3\Scripts\,例如set PATH=%PATH%;C:\Anaconda3;C:\Anaconda3\Scripts\

您可以通过powershell进行此操作(请参见上文,https: //msdn.microsoft.com/zh-cn/library/windows/desktop/bb776899(v = vs.85).aspx ),或按一下windows键→输入environment→选择从settings→→ edit environment variables for your account选择Path变量Edit→→ New

要测试它,请打开一个新的dos外壳,您现在应该可以使用conda命令。例如,尝试conda --version

In Windows, you will have to set the path to the location where you installed Anaconda3 to.

For me, I installed anaconda3 into C:\Anaconda3. Therefore you need to add C:\Anaconda3 as well as C:\Anaconda3\Scripts\ to your path variable, e.g. set PATH=%PATH%;C:\Anaconda3;C:\Anaconda3\Scripts\.

You can do this via powershell (see above, https://msdn.microsoft.com/en-us/library/windows/desktop/bb776899(v=vs.85).aspx ), or hit the windows key → enter environment → choose from settingsedit environment variables for your account → select Path variable → EditNew.

To test it, open a new dos shell, and you should be able to use conda commands now. E.g., try conda --version.


回答 1

在conda 4.6之后,情况发生了变化

程序“ Anaconda Prompt”和“ Anaconda Powershell”会conda自动为您显示命令。在启动菜单中找到它们。

如果您不想使用上面的提示,请尝试conda使用普通cmd.exe和Powershell。阅读以下内容。


暴露conda在每个shell

以下内容的目的是使命令在Windows condacmd.exe和Powershell中均可用。

如果在Anaconda安装过程中已选中“将Anaconda添加到我的PATH环境变量”,请跳过步骤1。

  1. 如果Anaconda仅安装用于当前用途,则将%USERPROFILE%\Anaconda3\condabin(我的意思是condabin,不是Scripts)添加到环境变量PATH(用户一个)中。如果您的计算机上的所有用户都安装了Anaconda,请添加C:\ProgramData\Anaconda3\condabin到中PATH

    如何在Windows上设置系统环境变量?

  2. 打开一个新的 Powershell,一次运行以下命令进行初始化conda

    conda init

这些步骤确保conda命令显示在您的cmd.exePowershell中。


扩展阅读:conda init来自Conda 4.6

警告:将新内容添加到您的中,\path\to\anaconda3\condabin但不要添加。这是4.6中引入的重大更改\path\to\anaconda3\ScriptsPATHconda

激活脚本初始化fron conda4.6发布日志

Conda 4.6添加了广泛的初始化支持,因此可以使用新conda activate命令的外壳比以前更多。有关更多信息,请阅读的输出。conda init –help对于这种新的工作方式,我们特别感到兴奋,因为消除了修改需求,PATH使Conda对系统上其他软件的破坏性大大降低。

在过去,这\path\to\anaconda3\Scripts是您的必备条件PATH。它conda同时在“基本”环境中公开命令和默认Python。

conda4.6 之后,conda相关命令分为condabin。这样就可以公开仅命令,conda而无需从“基本”环境中激活Python。

参考文献

Things have been changed after conda 4.6.

Programs “Anaconda Prompt” and “Anaconda Powershell” expose the command conda for you automatically. Find them in your startup menu.

If you don’t wanna use the prompts above and try to make conda available in a normal cmd.exe and a Powershell. Read the following content.


Expose conda in Every Shell

The purpose of the following content is to make command conda available both in cmd.exe and Powershell on Windows.

If you have already checked “Add Anaconda to my PATH environment variable” during Anaconda installation, skip step 1.

  1. If Anaconda is installed for the current use only, add %USERPROFILE%\Anaconda3\condabin (I mean condabin, not Scripts) into the environment variable PATH (the user one). If Anaconda is installed for all users on your machine, add C:\ProgramData\Anaconda3\condabin into PATH.

    How do I set system environment variables on Windows?

  2. Open a new Powershell, run the following command once to initialize conda.

    conda init
    

These steps make sure the conda command is exposed into your cmd.exe and Powershell.


Extended Reading: conda init from Conda 4.6

Caveat: Add the new \path\to\anaconda3\condabin but not \path\to\anaconda3\Scripts into your PATH. This is a big change introduced in conda 4.6.

Activation script initialization fron conda 4.6 release log

Conda 4.6 adds extensive initialization support so that more shells than ever before can use the new conda activate command. For more information, read the output from conda init –help We’re especially excited about this new way of working, because removing the need to modify PATH makes Conda much less disruptive to other software on your system.

In the old days, \path\to\anaconda3\Scripts is the one to be put into your PATH. It exposes command conda and the default Python from “base” environment at the same time.

After conda 4.6, conda related commands are separated into condabin. This makes it possible to expose ONLY command conda without activating the Python from “base” environment.

References


回答 2

现在在Windows上安装anaconda时,它不会自动添加Python或Conda。

如果您不知道conda和/或python在哪里,请在anaconda提示符下键入以下命令

接下来,您可以在命令提示符下使用setx命令将Python和Conda添加到路径中。

接下来,关闭该命令提示符并打开一个新命令。恭喜您现在可以使用conda和python

来源:https : //medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444

When you install anaconda on windows now, it doesn’t automatically add Python or Conda.

If you don’t know where your conda and/or python is, you type the following commands into your anaconda prompt

Next, you can add Python and Conda to your path by using the setx command in your command prompt.

Next close that command prompt and open a new one. Congrats you can now use conda and python

Source: https://medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444


回答 3

用于Windows的最新版本的Anaconda安装程序还将为“ Anaconda Prompt”和“ Anaconda Powershell Prompt”安装Windows启动器。如果您使用其中之一而不是常规的Windows cmd Shell,则conda默认情况下,此Shell中应使用命令python等。

The newest version of the Anaconda installer for Windows will also install a windows launcher for “Anaconda Prompt” and “Anaconda Powershell Prompt”. If you use one of those instead of the regular windows cmd shell, the conda command, python etc. should be available by default in this shell.


回答 4

如果要在Windows的常规cmd中使用Anaconda,则需要向Path env变量添加几个路径。

这些路径是(根据 PC 上的Anaconda版本文件夹可能是Anaconda2而不是Anaconda2):

\Users\YOUR_USER\Anaconda3
\Users\YOUR_USER\Anaconda3\Library\mingw-w64\bin
\Users\YOUR_USER\Anaconda3\Library\usr\bin
\Users\YOUR_USER\Anaconda3\Library\bin
\Users\YOUR_USER\Anaconda3\Scripts
\Users\YOUR_USER\Anaconda3\bin

If you want to use Anaconda in regular cmd on windows you need to add several paths to your Path env variable.

Those paths are (instead of Anaconda3 the folder may be Anaconda2 depending on the Anaconda version on your PC):

\Users\YOUR_USER\Anaconda3
\Users\YOUR_USER\Anaconda3\Library\mingw-w64\bin
\Users\YOUR_USER\Anaconda3\Library\usr\bin
\Users\YOUR_USER\Anaconda3\Library\bin
\Users\YOUR_USER\Anaconda3\Scripts
\Users\YOUR_USER\Anaconda3\bin

回答 5

一个小时前,我也遇到了同样的问题。我试图用Python安装QuTip Quantum Toolbox 不幸的是,我没有及时发现该页面。假设您已经下载了Anaconda安装程序并运行到最后。天真地,我在Windows 10中打开了命令提示符,然后继续输入qutip installation docs中给出的以下命令。

康达创建-n qutip-env

conda配置-添加通道conda-forge

康达安装qutip

但是,当我键入第一行时,我得到以下响应

不能将conda识别为内部或外部命令,可操作程序或批处理文件

错误消息

我继续尝试了一些其他操作,如该数字 错误消息所示。 最后,在访问了多个conda网站之后,我了解了如何解决此问题。在底部的搜索栏中输入Anaconda提示符,如下所示(在同一位置您赞美Cortana) Anaconda提示符

一旦您在这里,所有的conda命令将照常工作

I had also faced the same problem just an hour back. I was trying to install QuTip Quantum Toolbox in Python Unfortunately, I didn’t stumble onto this page in time. Say you have downloaded Anaconda installer and run it until the end. Naively, I opened the command prompt in windows 10 and proceded to type the following commands as given in the qutip installation docs.

conda create -n qutip-env

conda config –append channels conda-forge

conda install qutip

But as soon as I typed the first line I got the following response

conda is not recognized as an internal or external command, operable program or batch file

error messsage

I went ahead and tried some other things as seen in this figures error message Finally after going through a number conda websites, I understood how one fixes this problem. Type Anaconda prompt in the search bar at the bottom like this (same place where you hail Cortana) Anaconda prompt

Once you are here all the conda commands will work as usual


回答 6

如果您已安装Visual Studio 2017(专业版)

安装位置:

C:\ProgramData\Anaconda3\Scripts

如果您不希望将其放入Windows的path环境变量中并重新启动,可以通过以下简单方式运行它:

C:\>"C:\ProgramData\Anaconda3\Scripts\conda.exe" update qt pyqt

If you have installed Visual studio 2017 (profressional)

The install location:

C:\ProgramData\Anaconda3\Scripts

If you do not want the hassle of putting this in your path environment variable on windows and restarting you can run it by simply:

C:\>"C:\ProgramData\Anaconda3\Scripts\conda.exe" update qt pyqt

回答 7

甚至在我初次安装Anaconda时遇到了同样的问题。它说找不到“ conda”命令。

因此,我只设置了两个值[在PATH变量中添加了Anaconda的两个新路径]系统环境变量:C:\ Users \ mshas \ Anaconda2 \和C:\ Users \ mshas \ Anaconda2 \ Scripts

很多人忘记添加第二个变量“ Scripts”,而只需添加“ conda”命令即可。

Even I got the same problem when I’ve first installed Anaconda. It said ‘conda’ command not found.

So I’ve just setup two values[added two new paths of Anaconda] system environment variables in the PATH variable which are: C:\Users\mshas\Anaconda2\ & C:\Users\mshas\Anaconda2\Scripts

Lot of people forgot to add the second variable which is “Scripts” just add that then ‘conda’ command works.


回答 8

您需要将C://…/Anaconda3安装文件中的python.exe以及C://…/Anaconda3/Scripts添加到PATH。

首先转到您的安装目录,在我的情况下,它安装在C:// Users / user / Anaconda3中,并按住Shift键并单击鼠标右键,然后按“在此处打开命令窗口”,或者如果是powershell,则可能是“在此处打开powershell” ,只需编写cmd并按Enter键即可运行命令窗口。然后运行以下命令setx PATH%cd%

然后转到C:// Users / user / Anaconda3 / Scripts并在上面打开命令窗口,然后运行相同的命令“ setx PATH%cd%”

You need to add the python.exe in C://…/Anaconda3 installation file as well as C://…/Anaconda3/Scripts to PATH.

First go to your installation directory, in my case it is installed in C://Users/user/Anaconda3 and shift+right click and press “Open command window here” or it might be “Open powershell here”, if it is powershell, just write cmd and hit enter to run command window. Then run the following command setx PATH %cd%

Then go to C://Users/user/Anaconda3/Scripts and open the command window there as above, then run the same command “setx PATH %cd%”


回答 9

情况#1 您应设置3条路径:

%ANACONDAPATH%;
%ANACONDAPATH%\Scripts;
%ANACONDAPATH%\Library\bin;

它将解决问题:

C:\WINDOWS\system32>conda update conda
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/msys2/noarch/repodata.json.bz2>
Elapsed: -
...

案例2 您还可以使用Anaconda Promd(用于Win10)代替CLI(cmd.exe)

case #1 You should set 3 path:

%ANACONDAPATH%;
%ANACONDAPATH%\Scripts;
%ANACONDAPATH%\Library\bin;

It will solve problem:

C:\WINDOWS\system32>conda update conda
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/msys2/noarch/repodata.json.bz2>
Elapsed: -
...

case #2 Also you can use Anaconda Promd (for Win10) instead CLI (cmd.exe)


回答 10

为了防止SSL出现其他问题,您应该将所有这些都添加到Path中:

 SETX PATH "%PATH%;C:\<path>\Anaconda3;C:\<path>\Anaconda3\Scripts;C:\<path>\Anaconda3\Library\bin"

请求(由SSLError引起(“由于SSL模块不可用,无法连接到HTTPS URL。”)PyCharm请求网站中的错误

To prevent having further issues with SSL you should add all those to Path :

 SETX PATH "%PATH%;C:\<path>\Anaconda3;C:\<path>\Anaconda3\Scripts;C:\<path>\Anaconda3\Library\bin"

Requests (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”) Error in PyCharm requesting website


同时安装Anacondas 2.7和3.5可以吗?

问题:同时安装Anacondas 2.7和3.5可以吗?

我目前正在将Anaconda与Python 2.7一起使用,但是我将需要使用Python 3.5。可以同时安装它们吗?我应该期待一些问题吗?
我使用的是64位Win8。

I am using currently Anaconda with Python 2.7, but I will need to use Python 3.5. Is it ok to have them installed both in the same time? Should I expect some problems?
I am on a 64-bit Win8.


回答 0

我的理解是,您无需再次安装Anaconda即可开始使用其他版本的python。相反,conda 可以单独管理python 2和3环境

My understanding is you don’t need to install Anaconda again to start using a different version of python. Instead, conda has the ability to separately manage python 2 and 3 environments.


回答 1

我会同时使用这两种方法,具体取决于我所帮助的部门(有些人喜欢2.7,有些人则喜欢3.5)。无论如何,我使用Anaconda,默认安装为3.5。我将环境用于其他版本的python,软件包等。因此,例如,当我想开始使用python 2.7时,我运行了:

 conda create -n Python27 python=2.7

这将创建一个名为Python27的新环境并安装Python版本2.7。您可以在该行中添加参数以默认情况下安装其他软件包,也可以只是从头开始。该环境将自动激活,只需在命令行中键入deactivate(windows)或source deactivate(linux,osx)即可停用。要在以后激活,请键入activate Python27(windows)或source activate Python27(linux,osx)。如果您选择采用那条路线,我建议您阅读Anaconda中的管理环境文档。

更新资料

conda4.6版开始,您现在可以使用conda activateconda deactivate。采用source现在已被弃用,最终将被删除。

I use both depending on who in my department I am helping (Some people prefer 2.7, others 3.5). Anyway, I use Anaconda and my default installation is 3.5. I use environments for other versions of python, packages, etc.. So for example, when I wanted to start using python 2.7 I ran:

 conda create -n Python27 python=2.7

This creates a new environment named Python27 and installs Python version 2.7. You can add arguments to that line for installing other packages by default or just start from scratch. The environment will automatically activate, to deactivate simply type deactivate (windows) or source deactivate (linux, osx) in the command line. To activate in the future type activate Python27 (windows) or source activate Python27 (linux, osx). I would recommend reading the documentation for Managing Environments in Anaconda, if you choose to take that route.

Update

As of conda version 4.6 you can now use conda activate and conda deactivate. The use of source is now deprecated and will eventually be removed.


回答 2

是的你可以。

您不必都下载两个Anaconda。

只有您需要下载Anaconda版本之一,并且需要激活其他版本的Anaconda python。

如果您拥有Python 3,则可以这样设置Python 2内核;

python2 -m pip install ipykernel

python2 -m ipykernel install --user

如果您有Python 2,

python3 -m pip install ipykernel

python3 -m ipykernel install --user

然后,您将能够看到两个版本的Python!

如果您正在使用Anaconda Spyder,则应在此处交换版本:

如果您使用的是木星,请在这里检查:

注意:如果安装后Jupiter或Anaconda已打开,则需要重新启动。然后您将能够看到。

Yes you can.

You don’t have to download both Anaconda.

Only you need to download one of the version of Anaconda and need activate other version of Anaconda python.

If you have Python 3, you can set up a Python 2 kernel like this;

python2 -m pip install ipykernel

python2 -m ipykernel install --user

If you have Python 2,

python3 -m pip install ipykernel

python3 -m ipykernel install --user

Then you will be able to see both version of Python!

If you are using Anaconda Spyder then you should swap version here:

If you are using Jupiter then check here:

Note: If your Jupiter or Anaconda already open after installation you need to restart again. Then you will be able to see.


回答 3

我已经安装了python 2.7.13和3.6.2。首先为python 3安装Anaconda,然后可以使用conda语法获得2.7。我的安装使用了:conda create -n py27 python = 2.7.13 anaconda

I have python 2.7.13 and 3.6.2 both installed. Install Anaconda for python 3 first and then you can use conda syntax to get 2.7. My install used: conda create -n py27 python=2.7.13 anaconda


回答 4

是的,可以同时安装两个版本。如今,实际上已经很期待了。2.7中编写了很多东西,但是3.5正在成为规范。我建议您尽快将所有python更新到3.5。

Yes, It should be alright to have both versions installed. It’s actually pretty much expected nowadays. A lot of stuff is written in 2.7, but 3.5 is becoming the norm. I would recommend updating all your python to 3.5 ASAP, though.


回答 5

Anaconda是根据您的要求制造的。它也是环境经理。它分离出环境。之所以这样做,是因为较新/不稳定的宿主语言版本不支持稳定和旧版软件包。因此,需要一种可以在同一台计算机上分离和管理这些版本的软件,而无需重新安装或卸载单个主机编程语言/环境。

您可以在Anaconda文档中找到环境的创建/删除。

希望这会有所帮助。

Anaconda is made for the purpose you are asking. It is also an environment manager. It separates out environments. It was made because stable and legacy packages were not supported with newer/unstable versions of host languages; therefore a software was required that could separate and manage these versions on the same machine without the need to reinstall or uninstall individual host programming languages/environments.

You can find creation/deletion of environments in the Anaconda documentation.

Hope this helped.


如何在虚拟环境中运行Spyder?

问题:如何在虚拟环境中运行Spyder?

我一直在使用随Anaconda发行版安装的Spyder,后者使用Python 2.7作为默认值。当前,我需要使用Python 3.4设置开发虚拟环境。

经过网上研究后,最重要的两个建议是:

  1. 首先建立虚拟环境并指出改变Spyder的偏好,例如在这里 ;
  2. 在虚拟环境本身中安装所有Spyder依赖项,例如PyQt4,例如在这里

两项建议都很繁琐,看起来也不是明智的开发选择。

有没有一种解决方案可以在激活所需的虚拟环境后自动使用所需的Python版本运行Spyder?

I have been using Spyder installed with with Anaconda distribution which uses Python 2.7 as default. Currently I need to set up a development virtual environment with Python 3.4.

Top two suggestions after research online are:

  1. to set up virtual environment first and to point change the preferences of Spyder , e.g here;
  2. to install all Spyder dependencies, like PyQt4, in the virtual environment itself, e. g. here ;

Both recommendations are cumbersome and do not look like smart options for development.

Is there a solution that would allow to run Spyder with required Python version automatically after activating the required virtual environment?


回答 0

这是在2020年实现的快速方法。使用Anaconda Navigator:

  1. 打开Anaconda Navigator
  2. 根据需要创建新环境。我将此环境命名为“测试”。单击它将其激活。

  1. 转到“主页”,然后在Spyder框下单击“安装”。

  1. 点击“启动/运行”

设置环境时,仍然存在一些小错误(大多数问题可以通过重新启动Navigator来解决),如果发现错误,请将其发布到Anaconda Issues bug-tracker中。谢谢。


如果仍然无法解决问题,导航器仍然有用,单击>环境会将您带到该环境中安装的模块的管理窗口,搜索并选择与spyder相关的模块,然后单击应用将安装它们并他们的依赖性。

Here is a quick way to do it in 2020. Using the Anaconda Navigator:

  1. Open Anaconda Navigator
  2. Create your new environment as you wish. I named this environment “test”. Click on it to activate it.

  1. Go to “Home” and click on “Install” under the Spyder box.

  1. Click “Launch/Run”

There are still some minor bugs when setting up your environment (most of which are solved by restarting the Navigator), if you find a bug, please post it in Anaconda Issues bug-tracker. Thanks.


If even then this doesn’t work, Navigator could still be useful, clicking on >Enviroments takes you to a management window for the modules installed on such enviroment, searching and selecting the spyder related ones, and then clicking on Apply will install them and their dependencies.


回答 1

有一个选项可以使用所需的Python版本在Anaconda中创建虚拟环境

conda create -n myenv python=3.4

要激活它:

source activate myenv   # (in linux, you can use . as a shortcut for "source")
activate myenv          # (in windows - note that you should be in your c:\anaconda2 directory)

更新。我已经在Ubuntu 18.04上对其进行了测试。现在,您必须使用此命令为新环境另外安装spyder(在使用上述命令激活环境之后):

conda install spyder

(我也用pip测试了安装,但是对于Python 3.4或更早版本,它会因需要手动安装的库依赖关系错误而中断。)

现在,要在Python 3.4中运行Spyder,只需键入:

spyder

读者编辑:

对于一个正常的开立,使用“Python提示符”> > activate myenvspyder那么“巨蟒提示”必须保持开放的,你不能将其用于其他命令和强制关闭将关闭Spyder的)。当然,这要比长时间加载“ Anaconda Navigator”>切换环境>启动Spyder(@adelriosantiago的答案)更快。

There is an option to create virtual environments in Anaconda with required Python version.

conda create -n myenv python=3.4

To activate it :

source activate myenv   # (in linux, you can use . as a shortcut for "source")
activate myenv          # (in windows - note that you should be in your c:\anaconda2 directory)

UPDATE. I have tested it with Ubuntu 18.04. Now you have to install spyder additionally for the new environment with this command (after the activation of the environment with the command above):

conda install spyder

(I have also tested the installation with pip, but for Python 3.4 or older versions, it breaks with the library dependencies error that requires manual installation.)

And now to run Spyder with Python 3.4 just type:

spyder

EDIT from a reader:

For a normal opening, use “Anaconda Prompt” > activate myenv > spyder (then the “Anaconda Prompt” must stay open, you cannot use it for other commands, and a force-close will shut down Spyder). This is of course faster than the long load of “Anaconda Navigator” > switch environment > launch Spyder (@adelriosantiago’s answer).


回答 2

tomaskazemekas的回答的附加内容:您应该通过以下方式在该虚拟环境中安装spyder:

conda install -n myenv spyder

(在Windows上,对于Linux或MacOS,您可以搜索类似的命令)

Additional to tomaskazemekas’s answer: you should install spyder in that virtual environment by:

conda install -n myenv spyder

(on Windows, for Linux or MacOS, you can search for similar commands)


回答 3

对我有用的是:

  1. 从环境中运行间谍程序(激活源后)
  2. 转到工具->首选项-> python解释器,然后从您要链接到spyder en 的env中选择python文件:/ home / you / anaconda3 / envs / your_env / bin / python

在ubuntu 16,spyder3,python3.6上工作。

What worked for me :

  1. run spyder from the environment (after source activate)
  2. go to Tools –> preferences –> python Interpreter and select the python file from the env you want to link to spyder ex : /home/you/anaconda3/envs/your_env/bin/python

Worked on ubuntu 16, spyder3, python3.6.


回答 4

在所有环境中都无需重新安装spyder的情况下,请遵循此处的官方参考。

总结(用conda测试):

  • Spyder应该安装在基本环境中

在系统提示下:

  • 创建一个新的环境。请注意,根据创建方式(conda,virtualenv),环境文件夹将位于系统上的其他位置)

  • 激活环境(例如conda activate [yourEnvName]

  • 在环境中安装间谍内核(例如conda install spyder-kernels

  • 在环境中查找并复制python可执行文件的路径。查找此路径可以使用提示符以下命令来完成python -c "import sys; print(sys.executable)"

  • 停用环境(即返回基地conda deactivate

  • 运行间谍(spyder3

  • 最后,在spyder的“工具”菜单中,转到“首选项”>“ Python解释器”>“使用以下解释器”,然后粘贴环境python可执行文件路径。

  • 重新启动ipython控制台

PS:在间谍中,您应该在底部看到这样的内容

沃伊拉

To do without reinstalling spyder in all environments follow official reference here.

In summary (tested with conda):

  • Spyder should be installed in the base environment

From the system prompt:

  • Create an new environment. Note that depending on how you create it (conda, virtualenv) the environment folder will be located at different place on your system)

  • Activate the environment (e.g., conda activate [yourEnvName])

  • Install spyder-kernels inside the environment (e.g., conda install spyder-kernels)

  • Find and copy the path for the python executable inside the environment. Finding this path can be done using from the prompt this command python -c "import sys; print(sys.executable)"

  • Deactivate the environment (i.e., return to base conda deactivate)

  • run spyder (spyder3)

  • Finally in spyder Tool menu go to Preferences > Python Interpreter > Use the following interpreter and paste the environment python executable path

  • Restart the ipython console

PS: in spyder you should see at the bottom something like this

Voila


回答 5

上面的答案是正确的,但是我spyder在virtualenv中调用仍会使用PATH默认的anaconda env查找spyder的版本。我发现此答案提供了以下解决方法:

source activate my_env            # activate your target env with spyder installed
conda info -e                     # look up the directory of your conda env
find /path/to/my/env -name spyder # search for the spyder executable in your env
/path/to/my/env/then/to/spyder    # run that executable directly

我选择此方法的目的PATH是优先于修改或添加指向可执行文件的链接,PATH因为我认为这样做不太可能破坏其他程序。但是,我确实在中为可执行文件添加了别名~/.bash_aliases

The above answers are correct but I calling spyder within my virtualenv would still use my PATH to look up the version of spyder in my default anaconda env. I found this answer which gave the following workaround:

source activate my_env            # activate your target env with spyder installed
conda info -e                     # look up the directory of your conda env
find /path/to/my/env -name spyder # search for the spyder executable in your env
/path/to/my/env/then/to/spyder    # run that executable directly

I chose this over modifying PATH or adding a link to the executable at a higher priority in PATH since I felt this was less likely to break other programs. However, I did add an alias to the executable in ~/.bash_aliases.


回答 6

我只是在尝试使Spyder在虚拟环境中运行时遇到相同的问题。

解决方案很简单:

激活您的虚拟环境。

然后在您的虚拟环境中pip安装Spyder及其依赖项(PyQt5)。

然后从您的虚拟环境CLI启动Spyder3。

现在对我来说很好。

I just had the same problem trying to get Spyder to run in Virtual Environment.

The solution is simple:

Activate your virtual environment.

Then pip install Spyder and its dependencies (PyQt5) in your virtual environment.

Then launch Spyder3 from your virtual environment CLI.

It works fine for me now.


回答 7

在Windows上:

您可以创建一个快捷方式执行

Anaconda3\pythonw.exe Anaconda3\cwp.py Anaconda3\envs\<your_env> Anaconda3\envs\<your env>\pythonw.exe Anaconda3\envs\<your_env>\Scripts\spyder-script.py

但是,如果您从Anaconda外壳中的venv启动spyder,我相信它会为您创建此快捷方式(只需在Windows上搜索“ Spyder”)。

On Windows:

You can create a shortcut executing

Anaconda3\pythonw.exe Anaconda3\cwp.py Anaconda3\envs\<your_env> Anaconda3\envs\<your env>\pythonw.exe Anaconda3\envs\<your_env>\Scripts\spyder-script.py

However, if you started spyder from your venv inside Anaconda shell, it creates this shortcut for you automatically in the Windows menu. The steps:

  1. install spyder in your venv using the methods mentioned in the other answers here.

  2. (in anaconda:) activate testenv

  3. Look up the windows menu “recently added” or just search for “spyder” in the windows menu, find spyder (testenv) and

  • [add that to taskbar] and / or

  • [look up the file source location] and copy that to your desktop, e.g. from C:\Users\USER\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Anaconda3 (64-bit), where the spyder links for any of my environments can be found.

Now you can directly start spyder from a shortcut without the need to open anaconda prompt.


回答 8

我遵循上述建议之一,并且确实有效。总而言之,使用上述建议在Ubuntu上下载Anaconda时,可以帮助您“创建”环境。在我的情况下,下载Spyder的默认值为:(base)smith @ ubuntu〜$。创建环境(即fenics并使用$ conda激活它)后,立即激活(fenics)smith @ ubuntu〜$。然后从该提示启动Spyder,即$ spyder然后您的系统打开Spyder IDE,您可以在其上编写fenics代码。记住,每次打开终端时,系统都会打开默认提示。您必须激活您的包装所在的环境,并迅速更改它,即(fenics)。我希望这将有所帮助。谢谢您以及所有提供帮助的人。这个社区很棒。

I follow one of the advice above and indeed it works. In summary while you download Anaconda on Ubuntu using the advice given above can help you to ‘create’ environments. The default when you download Spyder in my case is: (base) smith@ubuntu ~$. After you create the environment, i.e. fenics and activate it with $ conda activate fenics the prompt change to (fenics) smith@ubuntu ~$. Then you launch Spyder from this prompt, i.e $ spyder and your system open the Spyder IDE, and you can write fenics code on it. Remember every time you open a terminal your system open the default prompt. You have to activate your environment where your package is and the prompt change to it i.e. (fenics). I Hope this will help. Thank you as well as all the people who help. This community is great.


如何更改默认的Anaconda python环境

问题:如何更改默认的Anaconda python环境

我已经安装了Anaconda,并创建了两个额外的环境:py3k(具有Python 3.3)和py34(具有Python 3.4)。除此之外,我还有一个默认环境“ root”,该环境由Anaconda安装程序默认创建,并包含Python 2.7。最后一个是默认值,每当我从终端启动“ ipython”时,它就会给我2.7版本。为了使用Python 3.4,我需要发出命令(在shell中)

source activate py34
ipython

它将默认环境更改为Python 3.4。这很好用,但是很烦人,因为我大部分时间都在使用Python 3.4而不是Python 2.7(我出于教学目的持有这是一个很长的故事)。无论如何,我想知道如何将默认环境更改为Python 3.4,但要记住我不想从头开始重新安装所有内容。

I’ve installed Anaconda and created two extra environments: py3k (which holds Python 3.3) and py34 (which holds Python 3.4). Besides those, I have a default environment named ‘root’ which the Anaconda installer created by default and which holds Python 2.7. This last one is the default, whenever I launch ‘ipython’ from the terminal it gives me version 2.7. In order to work with Python 3.4, I need to issue the commands (in the shell)

source activate py34
ipython

which change the default environment to Python 3.4. This works fine, but it’s annoying since most of the time I work on Python 3.4, instead of Python 2.7 (which I hold for teaching purposes, it’s a rather long story). Anyway, I’ll like to know how to change the default environment to Python 3.4, bearing in mind that I don’t want to reinstall everything from scratch.


回答 0

如果您只想更改为其他环境,请使用

source activate environment-name

(您可以environment-name使用`conda create创建)


通常,最好只是创建新环境。但是,如果您确实想在默认环境中更改Python版本,则可以执行以下操作:

首先,通过运行确保您拥有最新版本的conda

conda update conda

然后跑

conda install python=3.5

这将尝试将根环境中的所有软件包更新为Python 3版本。如果不可能(例如,因为某些软件包不是为Python 3.5构建的),它将向您显示一条错误消息,指出哪个软件包导致了问题。

如果您使用pip安装了软件包,则必须重新安装它们。

If you just want to change to another environment, use

source activate environment-name

(you can create environment-name with `conda create)


Typically it’s best to just create new environments. However, if you really want to change the Python version in the default environment, you can do so as follows:

First, make sure you have the latest version of conda by running

conda update conda

Then run

conda install python=3.5

This will attempt to update all your packages in your root environment to Python 3 versions. If it is not possible (e.g., because some package is not built for Python 3.5), it will give you an error message indicating which package(s) caused the issue.

If you installed packages with pip, you’ll have to reinstall them.


回答 1

概述
出于兼容性原因,某些人具有多个具有不同版本python的Anaconda环境。在这种情况下,您应该具有一个设置默认环境的脚本。使用这种方法,您可以保留您在环境中使用的python版本。

以下假设environment_name是您的环境的名称

Mac / Linux:
编辑您的bash配置文件,使最后一行是source activate environment_name。在Mac OSX中,这是〜/ .bash_profile,在其他环境中,这可能是〜/ .bashrc

示例:
这是我在Mac OSX上的操作方式

  1. 打开终端并输入:

    nano ~/.bash_profile

  2. 转到文件末尾并键入以下内容,其中“ p3.5”是我的环境:

    source activate p3.5

  3. 退出文件。启动一个新的终端窗口。

  4. 输入以下内容以查看活跃的环境

    conda info -e

结果表明,默认情况下我正在使用我的p3.5环境。

对于Windows:在打开命令提示符时,
使用创建一个命令文件(.cmd),activate environment_name并按照以下说明执行该文件。

  1. 创建一个批处理文件命令,例如“ my_conda.cmd”,将其放入“应用程序数据”文件夹中。
  2. 将其配置为在每次打开时自动启动cmd。此设置位于注册表中:注册表
    项:HKCU \ SOFTWARE \ Microsoft \ Command处理器
    值:自动运行
    类型:REG_EXPAND_SZ
    数据:“%AppData%\ my_conda.cmd”

从这个答案:https//superuser.com/a/302553/143794

Overview
Some people have multiple Anaconda environments with different versions of python for compatibility reasons. In this case, you should have a script that sets your default environment. With this method, you can preserve the versions of python you use in your environments.

The following assumes environment_name is the name of your environment

Mac / Linux:
Edit your bash profile so that the last line is source activate environment_name. In Mac OSX this is ~/.bash_profile, in other environments this may be ~/.bashrc

Example:
Here’s how i did it on Mac OSX

  1. Open Terminal and type:

    nano ~/.bash_profile

  2. Go to end of file and type the following, where “p3.5” is my environment:

    source activate p3.5

  3. Exit File. Start a new terminal window.

  4. Type the following to see what environment is active

    conda info -e

The result shows that I’m using my p3.5 environment by default.

For Windows:
Create a command file (.cmd) with activate environment_name and follow these instructions to have it execute whenever you open a command prompt

  1. Create a batch file command, e.g. “my_conda.cmd”, put it in the Application Data folder.
  2. Configure it to be started automatically whenever you open cmd. This setting is in Registry:
    key: HKCU\SOFTWARE\Microsoft\Command Processor
    value: AutoRun
    type: REG_EXPAND_SZ
    data: “%AppData%\my_conda.cmd”

from this answer: https://superuser.com/a/302553/143794


回答 2

在Linux下,有一种更简单的方法可以通过修改~/.bashrc或来设置默认环境。~/.bash_profile 最后,您会发现类似

# added by Anaconda 2.1.0 installer
export PATH="~/anaconda/bin:$PATH"

替换为

# set python3 as default
export PATH="~/anaconda/envs/python3/bin:$PATH"

这就是全部。

Under Linux there is an easier way to set the default environment by modifying ~/.bashrc or ~/.bash_profile At the end you’ll find something like

# added by Anaconda 2.1.0 installer
export PATH="~/anaconda/bin:$PATH"

Replace it with

# set python3 as default
export PATH="~/anaconda/envs/python3/bin:$PATH"

and thats all there is to it.


回答 3

对于Windows,Anaconda附带了Anaconda Prompt,它是cmd的快捷方式,可用于运行conda命令,而无需在PATH变量中添加anaconda。找到它的位置,复制并重命名该副本(例如myenv_prompt)。右键单击myenv_prompt,然后在上下文菜单中选择属性。

“ 属性”窗口的“ 目标”表单应该已经用文本填充,例如%windir%\system32\cmd.exe "/K" C:\Users\xxx\AppData\Local\Continuum\Miniconda3\Scripts\activate.bat C:\Users\xxx\AppData\Local\Continuum\Miniconda3\ 该命令的三个部分:1)启动… \ cmd.exe 2)运行… \使用环境3)\ acitvate.bat … \ Miniconda3 \

将第3部分更改为您想要默认设置的环境路径(例如myenv),即填写目标表单,例如%windir%\system32\cmd.exe "/K" C:\Users\xxx\AppData\Local\Continuum\Miniconda3\Scripts\activate.bat C:\Users\xxx\AppData\Local\Continuum\Miniconda3\envs\myenv

现在,myenv_prompt将充当以myenv作为python的默认环境启动cmd的快捷方式。您可以将此快捷方式保留在开始菜单中或固定在任务栏中。

此方法的一个优点是您可以创建一些快捷方式,每个快捷方式都具有不同的环境作为默认环境。您也可以通过 “属性”窗口的表单中填写“ 开始”来设置默认文件夹

希望这可以帮助

PS:不需要查找Anaconda Prompt,可以通过更改任何快捷方式的目标来完成。但是您将需要知道cmd.exe的路径和activate.bat

For windows Anaconda comes with Anaconda Prompt which is a shortcut to cmd and can be used run conda commands without adding anaconda in PATH variable. Find the location of it, copy and rename the copy (say myenv_prompt). Right click myenv_prompt and select properties in the context menu.

The Target form of Properties window should already be filled with text, something like %windir%\system32\cmd.exe "/K" C:\Users\xxx\AppData\Local\Continuum\Miniconda3\Scripts\activate.bat C:\Users\xxx\AppData\Local\Continuum\Miniconda3\ There are three parts of this command 1)start …\cmd.exe 2)run …\acitvate.bat with environment 3)…\Miniconda3\

Change 3rd part to path of the environment (say myenv) you want as default i.e. fill the Target form something like %windir%\system32\cmd.exe "/K" C:\Users\xxx\AppData\Local\Continuum\Miniconda3\Scripts\activate.bat C:\Users\xxx\AppData\Local\Continuum\Miniconda3\envs\myenv

Now myenv_prompt will act as shortcut to start cmd with myenv as the default environment for python. This shortcut you can keep in start menu or pinned in taskbar.

One advantage of this method is that you can create a few shortcuts each having different environment as default environment. Also you can set the default folder by filling Start in form of the Properties window

Hope this helps

PS:It is not required to find Anaconda Prompt and can be done by changing target of any shortcut. But you will require to know path of cmd.exe and activate.bat


回答 4

永久更改

conda install python={version}

临时更改

查看您的环境

运行conda info --envs终端窗口或Anconda上提示

如果未显示您要安装的环境

运行conda create -n py36 python=3.6 anacondapython 3.6更改版本作为您的首选

激活环境(使用Anaconda提示符)

运行activate envnmeenvnme,您可以conda info --envs在运行时通过此命令作为示例conda info --envs显示

base * C:\Users\DulangaHeshan\Anaconda3 py36 C:\Users\DulangaHeshan\Anaconda3\envs\py36

然后跑 activate py36

检查运行 python --version

在Windows中,优良作法是在激活另一个环境之前先停用它。 https://docs.conda.io/projects/conda/zh/latest/user-guide/tasks/manage-environments.html?highlight=deactivate%20environment

Change permanent

conda install python={version}

Change Temporarily

View your environments

run conda info --envs on your terminal window or an Anconda Prompt

If It doesn’t show environment that you want to install

run conda create -n py36 python=3.6 anaconda for python 3.6 change version as your prefer

Activating an environment (use Anaconda prompt)

run activate envnme envnme you can find by this commandconda info --envs as a example when you run conda info --envs it show

base * C:\Users\DulangaHeshan\Anaconda3 py36 C:\Users\DulangaHeshan\Anaconda3\envs\py36

then run activate py36

to check run python --version

In Windows, it is good practice to deactivate one environment before activating another. https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html?highlight=deactivate%20environment


回答 5

正确的答案(截至2018年12月)是…你不能。升级conda install python=3.6可能会起作用,但是如果您有必需的但不能卸载的软件包,则可能无法升级。

Anaconda使用默认环境命名,base并且您不能使用相同的名称创建新的环境(例如python 3.6)。这是故意的。如果您希望基本的Anaconda为python 3.6,则正确的方法是为python 3.6安装Anaconda。作为软件包管理器,Anaconda的目标是封装不同的环境,因此为什么您必须在其中激活激活资源以及为什么不能随便安静地切换基本软件包,因为这可能会导致生产系统出现许多问题。

The correct answer (as of Dec 2018) is… you can’t. Upgrading conda install python=3.6 may work, but it might not if you have packages that are necessary, but cannot be uninstalled.

Anaconda uses a default environment named base and you cannot create a new (e.g. python 3.6) environment with the same name. This is intentional. If you want your base Anaconda to be python 3.6, the right way to do this is to install Anaconda for python 3.6. As a package manager, the goal of Anaconda is to make different environments encapsulated, hence why you must source activate into them and why you can’t just quietly switch the base package at will as this could lead to many issues on production systems.


回答 6

我对这里提出的任何答案都不满意,因为激活环境在我的平台上花费了几秒钟(无论出于何种原因)

我修改了路径变量,以使我想要作为默认环境的优先于实际默认环境。

就我而言,我使用以下命令针对“ py35”环境完成此操作:

setx PATH "%userprofile%\Anaconda3\envs\py35\;%PATH%"
setx PATH "%userprofile%\Anaconda3\envs\py35\Scripts;%PATH%"

要查找环境的存储位置,请激活它并输入where python。我不确定这种方法是否有缺点。由于它还会更改conda可执行文件的默认路径。如果是这种情况,请发表评论。

I wasn’t satisfied with any of the answers presented here, since activating an environment takes a few seconds on my platform (for whatever reason)

I modified my path variable so that the environment I want as default has priority over the actual default.

In my case I used the following commands to accomplish that for the environment “py35”:

setx PATH "%userprofile%\Anaconda3\envs\py35\;%PATH%"
setx PATH "%userprofile%\Anaconda3\envs\py35\Scripts;%PATH%"

to find out where your environment is stored, activate it and enter where python. I’m not sure yet if this approach has any downsides. Since it also changes the default path of the conda executable. If that should be the case, please comment.


回答 7

使用anaconda安装库时,出现了此错误。我的版本从Python 3. *升级到2.7,很多东西停止了工作。我发现的最佳解决方案是首先查看可用的最新版本:

conda search python

然后更新到所需的版本:

conda install python=3.*.*

资料来源:http : //chris35wills.github.io/conda_python_version/

其他有用的命令:

conda info
python --version

I got this when installing a library using anaconda. My version went from Python 3.* to 2.7 and a lot of my stuff stopped working. The best solution I found was to first see the most recent version available:

conda search python

Then update to the version you want:

conda install python=3.*.*

Source: http://chris35wills.github.io/conda_python_version/

Other helpful commands:

conda info
python --version

回答 8

在桌面或任务栏上创建anaconda提示的快捷方式,然后在该快捷方式的属性中确保将“ Target:”中的最后一个路径修改为您环境的路径:

C:\ Users \ BenBouali \ Anaconda3 \将更改为C:\ Users \ BenBouali \ Anaconda3 \ envs \ tensorflow-gpu

预习

这样,您可以在单击某个快捷方式时使用该快捷方式打开特定的环境,您也可以将其添加到您的路径中,现在您只需键入快捷方式的名称就可以从Windows运行框中运行它。

Create a shortcut of anaconda prompt onto desktop or taskbar, and then in the properties of that shortcut make sure u modify the last path in “Target:” to the path of ur environment:

C:\Users\BenBouali\Anaconda3\ WILL CHANGE INTO C:\Users\BenBouali\Anaconda3\envs\tensorflow-gpu

preview

and this way u can use that shortcut to open a certain environment when clicking it, you can add it to ur path too and now you’ll be able to run it from windows run box by just typing in the name of the shortcut.


回答 9

在Windows上,创建包含以下行的批处理文件:

start cmd /k "C:\Anaconda3\Scripts\activate.bat C:\Anaconda3 & activate env"

引号中包含的第一个路径是Anaconda安装中的activate.bat文件的路径。您系统上的路径可能不同。当然,激活命令后面的名称应该是您所需的环境名称。

然后在需要打开Anaconda提示符时运行批处理文件。

On Windows, create a batch file with the following line in it:

start cmd /k "C:\Anaconda3\Scripts\activate.bat C:\Anaconda3 & activate env"

The first path contained in quotes is the path to the activate.bat file in the Anaconda installation. The path on your system might be different. The name following the activate command of course should be your desired environment name.

Then run the batch file when you need to open an Anaconda prompt.


回答 10

加载你的 “基地”环境-如OP的py34-当你加载你的终端/壳。

如果您使用Bash,请输入以下行:

conda activate py34

在您.bash_profile(或.bashrc)中:

$ echo 'conda activate py34' >> ~/.bash_profile

每次运行新的终端时,py34都会加载conda环境。

Load your “base” environment — as OP’s py34 — when you load your terminal/shell.

If you use Bash, put the line:

conda activate py34

in your .bash_profile (or .bashrc):

$ echo 'conda activate py34' >> ~/.bash_profile

Every time you run a new terminal, conda environment py34 will be loaded.


anaconda更新所有可能的软件包吗?

问题:anaconda更新所有可能的软件包吗?

我尝试了conda search --outdated,其中有很多过时的软件包,例如scipy是0.17.1,但最新的是0.18.0。但是,当我这样做时conda update --all。它不会更新任何软件包。

更新1

conda update --all --alt-hint

Fetching package metadata .......
Solving package specifications: ..........

# All requested packages already installed.
# packages in environment at /home/user/opt/anaconda2:
#

更新2

我可以分别更新那些软件包。我能做conda update scipy。但是,为什么我不能一口气更新它们呢?

I tried the conda search --outdated, there are lots of outdated packages, for example the scipy is 0.17.1 but the latest is 0.18.0. However, when I do the conda update --all. It will not update any packages.

update 1

conda update --all --alt-hint

Fetching package metadata .......
Solving package specifications: ..........

# All requested packages already installed.
# packages in environment at /home/user/opt/anaconda2:
#

update 2

I can update those packages separately. I can do conda update scipy. But why I cannot update all of them in one go?


回答 0

TL; DR:依赖项冲突:更新一个要求 (根据要求)以降级另一个

你是对的:

conda update --all

实际上是要走的路1。Conda始终尝试将软件包升级到该系列的最新版本(例如Python 2.x或3.x)。

依赖冲突

但是有可能存在依赖性冲突(这会阻止进一步升级)。如果发生,康达通常会非常明确地发出警告。

例如X要求Y <5.0,因此Y永远不会> = 5.0

因此,您无法“全部”升级它们。

解决

补充说明:也许它可以工作,但是conda中没有使用Y> 5.0的X的较新版本。可以使用pip进行安装,因为pip中提供了更多软件包。但是请注意,如果存在依赖冲突,pip也会安装软件包,并且通常会破坏conda环境,因为您无法再可靠地使用conda进行安装。如果这样做,请在所有软件包都已安装conda之后作为最后的方法。这是一个hack。

您可以尝试的一种安全方法是在升级时将conda-forge作为渠道添加(-c conda-forge作为标志添加),或者如果确实需要此新版本,则可以找到包含软件包的任何其他渠道。这样,conda也会在此位置搜索可用的软件包。

考虑您的更新:您可以分别升级它们,但是这样做不仅包括升级,而且还包括其他软件包的降级。说,添加到上面的示例中:

X> 2.0要求Y <5.0,X <2.0要求Y> 5.0

因此,将Y> 5.0升级意味着将X降级到<2.0,反之亦然。

当然,这是一个教学示例,但实际上是相同的,通常只是具有更复杂的依赖性和子依赖性

因此,您仍然无法通过单独进行升级来全部升级它们。依赖关系是无法令人满意的,因此早晚要进行升级,升级将再次降级已经升级的软件包。或者破坏软件包的兼容性(通常您不希望这样做!),这只能通过显式调用ignore-dependenciesforce -command来实现。但是,这仅仅是破解围绕问题的方式,绝对不是正常用户的情况下!


1如果您实际上要更新安装软件包,而通常不这样做。在基本环境中运行的命令将以此更新软件包,但是通常您应该使用虚拟环境(conda create -n myenv然后使用conda activate myenv)。执行conda update --all这样的环境里将更新包这样的环境。但是,由于基本环境也是环境,因此答案以相同的方式适用于两种情况。

TL;DR: dependency conflicts: Updating one requires (by it’s requirements) to downgrade another

You are right:

conda update --all

is actually the way to go1. Conda always tries to upgrade the packages to the newest version in the series (say Python 2.x or 3.x).

Dependency conflicts

But it is possible that there are dependency conflicts (which prevent a further upgrade). Conda usually warns very explicitly if they occur.

e.g. X requires Y <5.0, so Y will never be >= 5.0

That’s why you ‘cannot’ upgrade them all.

Resolving

To add: maybe it could work but a newer version of X working with Y > 5.0 is not available in conda. It is possible to install with pip, since more packages are available in pip. But be aware that pip also installs packages if dependency conflicts exist and that it usually breaks your conda environment in the sense that you cannot reliably install with conda anymore. If you do that, do it as a last resort and after all packages have been installed with conda. It’s rather a hack.

A safe way you can try is to add conda-forge as a channel when upgrading (add -c conda-forge as a flag) or any other channel you find that contains your package if you really need this new version. This way conda does also search in this places for available packages.

Considering your update: You can upgrade them each separately, but doing so will not only include an upgrade but also a downgrade of another package as well. Say, to add to the example above:

X > 2.0 requires Y < 5.0, X < 2.0 requires Y > 5.0

So upgrading Y > 5.0 implies downgrading X to < 2.0 and vice versa.

(this is a pedagogical example, of course, but it’s the same in reality, usually just with more complicated dependencies and sub-dependencies)

So you still cannot upgrade them all by doing the upgrades separately; the dependencies are just not satisfiable so earlier or later, an upgrade will downgrade an already upgraded package again. Or break the compatibility of the packages (which you usually don’t want!), which is only possible by explicitly invoking an ignore-dependencies and force-command. But that is only to hack your way around issues, definitely not the normal-user case!


1 If you actually want to update the packages of your installation, which you usually don’t. The command run in the base environment will update the packages in this, but usually you should work with virtual environments (conda create -n myenv and then conda activate myenv). Executing conda update --all inside such an environment will update the packages inside this environment. However, since the base environment is also an environment, the answer applies to both cases in the same way.


回答 1

为了更精确地回答这个问题:

conda(对于anaconda而言,是miniconda的conda),仅在特定版本的软件包-> major和minor中更新所有内容。这就是范例。

在文档中,您会发现“注意:Conda更新到其系列中的最高版本,因此Python 2.7更新到了2.x系列中的最高版本,而3.6更新到了3.x系列中的最高版本。” doc

如果王先生没有提供可复制的例子,那么只能提供帮助。例如,这真的是他想要更新的虚拟环境吗?或者Wang是否可以得到他/她想要的东西

conda update -n ENVIRONMENT --all

*请在执行“ update –all”之前阅读文档!这自然不会导致所有软件包的更新。因为conda尝试解决环境中所有软件包之间的依赖关系,所以这可能导致DOWNGRADED软件包而没有警告。


如果您只想更新几乎所有内容,则可以创建一个密码文件

echo "conda ==4.0.0" >> ~/miniconda3/envs/py35/conda-meta/pinned
echo "numpy 1.7.*" >> ~/miniconda3/envs/py35/conda-meta/pinned

在运行更新之前。

如果以后要忽略环境中的文件进行更新,则可以执行以下操作:

conda update --all --no-pin

您不应该更新–all。但是,如果需要,您可以节省在克隆环境中进行测试。

第一步应该始终是备份当前规范:

conda list -n py35 --explicit 

(但即使如此,也不总是总是有指向源的链接,例如jupyterlab扩展)

接下来,您可以克隆和更新:

conda create -n py356 --clone py35

conda activate py356
conda config --set pip_interop_enabled True # for conda>=4.6
conda update --all

康达配置


更新:

因为conda的想法很好,但是在复杂的环境中效果不是很好,所以我个人更喜欢nix-shell (or lorri) and poetry[as as superior pip / conda .-)](intro poetry2nix)的组合。


最后,如果您确实需要使用由于依赖关系而导致不兼容的软件包,则可以使用NixOS / nix-pkgs之类的技术

To answer more precisely to the question:

conda (which is conda for miniconda as for Anaconda) updates all but ONLY within a specific version of a package -> major and minor. That’s the paradigm.

In the documentation you will find “NOTE: Conda updates to the highest version in its series, so Python 2.7 updates to the highest available in the 2.x series and 3.6 updates to the highest available in the 3.x series.” doc

If Wang does not gives a reproducible example, one can only assist. e.g. is it really the virtual environment he wants to update or could Wang get what he/she wants with

conda update -n ENVIRONMENT --all

*PLEASE read the docs before executing “update –all”! This does not lead to an update of all packages by nature. Because conda tries to resolve the relationship of dependencies between all packages in your environment, this can lead to DOWNGRADED packages without warnings.


If you only want to update almost all, you can create a pin file

echo "conda ==4.0.0" >> ~/miniconda3/envs/py35/conda-meta/pinned
echo "numpy 1.7.*" >> ~/miniconda3/envs/py35/conda-meta/pinned

before running the update. conda issues not pinned

If later on you want to ignore the file in your env for an update, you can do:

conda update --all --no-pin

You should not do update –all. If you need it nevertheless you are saver to test this in a cloned environment.

First step should always be to backup your current specification:

conda list -n py35 --explicit 

(but even so there is not always a link to the source available – like for jupyterlab extensions)

Next you can clone and update:

conda create -n py356 --clone py35

conda activate py356
conda config --set pip_interop_enabled True # for conda>=4.6
conda update --all

conda config


update:

Because the idea of conda is nice but it is not working out very well for complex environments I personally prefer the combination of nix-shell (or lorri) and poetry [as superior pip/conda .-)] (intro poetry2nix).

Alternatively you can use nix and mach-nix (where you only need you requirements file. It resolves and builds environments best.


Finally if you really need to work with packages that are not compatible due to its dependencies, it is possible with technologies like NixOS/nix-pkgs.


回答 2

想象一下软件包的依赖关系图,当软件包的数量增加时,在升级/添加软件包时遇到冲突的机会就会大大增加。为避免这种情况,只需在Anaconda中创建一个新环境。

节俭,只安装您需要的东西。对我来说,我在新环境中安装了以下软件包:

  • 大熊猫
  • scikit学习
  • matplotlib
  • 笔记本
  • 凯拉斯

我总共有84个包裹。

Imagine the dependency graph of packages, when the number of packages grows large, the chance of encountering a conflict when upgrading/adding packages is much higher. To avoid this, simply create a new environment in Anaconda.

Be frugal, install only what you need. For me, I installed the following packages in my new environment:

  • pandas
  • scikit-learn
  • matplotlib
  • notebook
  • keras

And I have 84 packages in total.


回答 3

如果在MS Windows中工作,则可以使用Anaconda导航器。单击环境,在下拉框中默认情况下为“已安装”。您可以选择“可更新”并从此处开始

if working in MS windows, you can use Anaconda navigator. click on the environment, in the drop-down box, it’s “installed” by default. You can select “updatable” and start from there


回答 4

更新我使用的所有可能的软件包 conda update --update-all

有用!

To update all possible packages I used conda update --update-all

It works!


回答 5

我用conda和解决了这个问题pip

首先,我运行:

conda uninstall qt and conda uninstall matplotlib and conda uninstall PyQt5

之后,我打开了cmd并运行以下代码

pip uninstall qt , pip uninstall matplotlib , pip uninstall PyQt5

最后,您应该matplotlib使用以下代码在pip中进行安装:pip install matplotlib

I solved this problem with conda and pip.

Firstly, I run:

conda uninstall qt and conda uninstall matplotlib and conda uninstall PyQt5

After that, I opened the cmd and run this code that

pip uninstall qt , pip uninstall matplotlib , pip uninstall PyQt5

Lastly, You should install matplotlib in pip by this code that pip install matplotlib