简体   繁体   English

安装Anaconda后无法安装Python模块

[英]Cannot Install Python Modules after Installing Anaconda

[New Note: I cannot install through binstar or anaconda. [新注意:我不能通过binstar或anaconda安装。 Why can't I install in python, outside of anaconda? 为什么我不能在蟒蛇外安装蟒蛇? Is there a way to get my computer to stop using the anaconda install of python when I don't luanch it specifically through the continuum launcher?] 有没有办法让我的电脑停止使用anaconda安装的python,因为我没有专门通过连续发射器来安装它?

I have an install of Python 2.7 on a windows machine. 我在Windows机器上安装了Python 2.7。 I just recently installed Anaconda, in addition. 我刚刚安装了Anaconda。

I just tried to install a new module for my Python install. 我只是尝试为我的Python安装安装一个新模块。 I opened a command prompt in an unzipped folder for a python module and ran: 我在解压缩的文件夹中为python模块打开了一个命令提示符并运行:

python setup.py install python setup.py安装

However, I experienced an error at build line: 但是,我在构建行遇到错误:

building 'pyodbc' extension 建立'pyodbc'扩展

The ultimate error line reads: 最终的错误行如下:

error: command 'gcc' failed with exit status 1 错误:命令'gcc'失败,退出状态为1

It appears to have looked for and not found several files or directories. 它似乎已经找到并找不到几个文件或目录。 For example, I received several (7) lines of error like: 例如,我收到了几(7)行错误,如:

gcc.exe: error: /Wall: No such file or directory gcc.exe:错误:/ Wall:没有这样的文件或目录

I have a wild hunch that the install of Anaconda is upsetting my PATH variables (or something), but it's just a hunch. 我有一种疯狂的预感,安装Anaconda会扰乱我的PATH变量(或其他东西),但这只是一种预感。

Thanks kindly. 谢天谢地。

You could try to find someone who's built this package on binstar , which is the package hosting site for Anaconda. 您可以尝试在binstar上找到构建此软件包的 ,这是Anaconda的软件包托管站点。

I found https://binstar.org/dhirschfeld/pyodbc/3.0.7/files , which may work for you if you have 64-bit Windows. 我找到了https://binstar.org/dhirschfeld/pyodbc/3.0.7/files ,如果你有64位Windows,它可能适合你。 You can try conda install -c https://conda.binstar.org/dhirschfeld pyodbc . 您可以尝试conda install -c https://conda.binstar.org/dhirschfeld pyodbc

It looks like you've downloaded the source for PyODBC and it contains some code that needs to be compiled (C/C++). 看起来你已经下载了PyODBC的源代码,它包含了一些需要编译的代码(C / C ++)。 Your error refers to the fact that you don't have gcc (a compiler) installed. 您的错误指的是您没有安装gcc (编译器)。

You can either install mingw32 or gcc (through cygwin) to build and install the module, but the easiest thing to do is probably just download the ODBC Windows installer from their Google Code site. 您可以安装mingw32gcc (通过cygwin)来构建和安装模块,但最简单的方法可能就是从他们的Google Code站点下载ODBC Windows安装程序

Your problem is that you do not have a C compiler ( gcc is a C compiler), which is needed in order for the package you downloaded to be installed. 您的问题是您没有C编译器( gcc是C编译器),这是为了安装您下载的软件包所必需的。 This problem is completely independent of Anaconda. 这个问题完全独立于Anaconda。

Your options are: 你的选择是:

  • Install a C compiler, and then build the package sources you downloaded (via the python setup.py install command) 安装C编译器,然后构建下载的包源(通过python setup.py install命令)
  • Find a pre-compiled version of the package. 找到包的预编译版本。

You did not say what platform you are on. 你没有说你在哪个平台上。 I suspect you are on a Mac or on Windows, since most Linux installations have a working C compiler. 我怀疑你在Mac或Windows上,因为大多数Linux安装都有一个可用的C编译器。

If you are on a Mac, please install Xcode via the App Store. 如果您使用的是Mac,请通过App Store安装Xcode。 This is the overall recommended way to get a C compiler on Mac OS X. 这是在Mac OS X上获得C编译器的总体推荐方法。

If you are on Windows, you should install the MinGW package via: 如果您使用的是Windows,则应通过以下方式安装MinGW软件包:

conda install mingw

Then you can try doing "python setup.py install". 然后你可以尝试做“python setup.py install”。

BTW, the difficulties you are encountering with building packages is common, and it's why people use a distribution like Anaconda, instead of struggling with build issues on their own. 顺便说一下,你遇到的构建软件包的困难是常见的,这就是为什么人们使用像Anaconda这样的发行版,而不是自己解决构建问题。 If you want to only use Anaconda part of the time, and use your system Python, then you can just set your PATH variable by editing ~/.bash_profile and commenting out the line at the very bottom which adds anaconda/bin/ to your path. 如果你只想在部分时间使用Anaconda,并使用你的系统Python,那么你可以通过编辑~/.bash_profile来设置你的PATH变量并注释掉最底部的行,这会在路径中添加anaconda/bin/

Managing packages across two different Python installations is going to cause you more headaches than it's generally worth. 跨两个不同的Python安装来管理包会让你比一般的价值更令人头疼。 I would recommend just using Anaconda, unless you have a very good reason to stick with the system Python. 我只想用蟒蛇,除非你有一个很好的理由,坚持使用Python的系统建议。

Enthought provides pre-built PyODBC package downloads in its repository for the standard platforms. Enthought在其标准平台的存储库中提供预构建的PyODBC包下载。 You will need a subscription to access this package though (this one is not part of the free Canopy Express version). 您需要订阅才能访问此软件包(此软件包不是免费的Canopy Express版本的一部分)。 If you are a faculty member or student, then you can get a free academic subscription: https://www.enthought.com/products/canopy/academic/ 如果您是教职员工或学生,那么您可以获得免费的学术订阅: https//www.enthought.com/products/canopy/academic/

I suggest trying "conda install" + PackageName. 我建议尝试“conda install”+ PackageName。 If it fails installing using conda, it may automatically jump to using pip with success. 如果使用conda安装失败,它可能会自动跳转到使用pip成功。

check out my answer over here. 看看我的回答。 https://stackoverflow.com/a/21764422/129600 https://stackoverflow.com/a/21764422/129600

basically, the pyodbc source code is missing stuff/has other out-of-date stuff, so the fix mentioned there should hopefully work for you. 基本上,pyodbc源代码缺少东西/有其他过时的东西,所以那里提到的修复应该有希望为你工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM