問題描述
我剛剛安裝了新的 VS2017 Preview 并導(dǎo)入了一個 Python 項目.這個項目有很多導(dǎo)入語句,但是 VS2017 確實在一些導(dǎo)入包中顯示錯誤,例如 cv2、socketio、eventlet、eventlet.wsgi.這個 Python 項目在我的 Anaconda 環(huán)境中運行良好,在 VS2017 之外.我需要在 Windows 中安裝 OpenCV 2、socketio 等嗎?或者VS2017環(huán)境下有沒有像pip、anaconda、apt-get這樣的解決方案可以自動安裝未解析的包?我還注意到可以將 Anaconda 添加到創(chuàng)建的 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.
推薦答案
可以,但并不完美.
首先,您需要調(diào)出 Python 環(huán)境菜單,可以通過以下方式訪問:
Firstly you need to bring up the Python Environments menu which can be accessed by going:
工具 -> Python -> Python 環(huán)境
Tools -> Python -> Python Environments
它應(yīng)該會彈出一個側(cè)邊欄(取決于您如何設(shè)置 VS).大約一半的地方應(yīng)該有一個帶有概述"文本的下拉框.單擊它,您可以選擇包".這將在其下方彈出一個文本框,允許您使用標(biāo)準(zhǔn) 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 上無法正常工作,因為標(biāo)準(zhǔn) 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 的非官方軟件包站點 和然后下載你需要的包.在本地下載后,只需將本地地址復(fù)制并粘貼到包"下的文本框中.然后它將安裝軟件包,您就可以開始了.
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.
這篇關(guān)于如何在 Visual Studio 2017 中將包添加到 python的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!