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

查看:277
本文介绍了如何在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 Environments菜单,该菜单可以通过以下方式访问:

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天全站免登陆