如何在 Visual Studio 2017 中将包添加到 python [英] How to add a package to python in Visual Studio 2017

查看:24
本文介绍了如何在 Visual Studio 2017 中将包添加到 python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了新的 VS2017 Preview 并导入了一个 Python 项目.这个项目有很多导入语句,但是 VS2017 确实在一些导入包中显示错误,例如 cv2、socketio、eventlet、eventlet.wsgi.这个 Python 项目在我的 Anaconda 环境中运行良好,在 VS2017 之外.我需要在 Windows 中安装 OpenCV 2、socketio 等吗?或者VS2017环境下有没有像pip、anaconda、apt-get这样的解决方案可以自动安装未解析的包?我还注意到可以将 Anaconda 添加到创建的 VS 项目中.VS 中的这个 Anaconda 可以帮助安装缺少的软件包吗?问候.

I just installed the new VS2017 Preview and imported a Python project. This project has many import statements but VS2017 does show error in some import packages like cv2, socketio, eventlet, eventlet.wsgi. This Python project runs fine, out of VS2017, in my Anaconda environment. Do I need to install OpenCV 2, socketio, etc in Windows? Or is there a solution like pip, anaconda, apt-get, in the VS2017 environment that can automate the installation of unresolved package? I also noticed that it is possible to add Anaconda to VS project created. Can this Anaconda inside VS help to install the missing packages? Regards.

推荐答案

可以,但并不完美.

首先,您需要调出 Python 环境菜单,可以通过以下方式访问:

Firstly you need to bring up the Python Environments menu which can be accessed by going:

工具 -> Python -> Python 环境

Tools -> Python -> Python Environments

它应该会弹出一个侧边栏(取决于您如何设置 VS).大约一半的地方应该有一个带有概述"文本的下拉框.单击它,您可以选择包".这将在其下方弹出一个文本框,允许您使用标准 pip 命令安装软件包.

It should bring up a sidebar (depending on how you have VS setup). There should be a dropdown box about half way down with the text "Overview". Click on that and you can select "Packages". This will bring up a textbox under it that will allow you to use standard pip commands to install packages.

如果您在 Windows 上,但某些软件包会增加一个步骤.由于 pip 在 Windows 上无法正常工作,因为标准 Windows 软件包站点 (PyPI) 确实还没有很多常用软件包的 Windows 轮子.

If you are on Windows though there is one added step for some packages though. As pip does not work well on Windows, due to the fact that the standard Windows package site (PyPI) does not yet have Windows wheels for a lot of common packages.

因此,您最好访问 Christoph Gohlke 的非官方软件包站点 和然后下载你需要的包.在本地下载后,只需将本地地址复制并粘贴到包"下的文本框中.然后它将安装软件包,您就可以开始了.

Therefore, you are best off going to Christoph Gohlke's unofficial package site and then downloading the package you need. Once it's downloaded locally just copy and paste the LOCAL address into the textbox under "Packages". It will then install the package and you'll be good to go.

这篇关于如何在 Visual Studio 2017 中将包添加到 python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆