简体   繁体   English

Windows上的Visual Studio 2017中的Python包(numpy / pandas / etc)

[英]Python packages (numpy/pandas/etc) in Visual Studio 2017 on Windows

I've just installed Visual Studio Community with the workloads for Python and Data Science. 我刚刚安装了Visual Studio社区,其中包含Python和Data Science的工作负载。

I create a new Regression project from the Python\\Machine Learning template. 我从Python \\ Machine Learning模板创建了一个新的回归项目。

The first few lines are: 前几行是:

from pandas import read_table
import numpy as np
import matplotlib.pyplot as plt

First I get the errors: No module named xxx or Missing required dependencies [xxx] , for pandas or numpy, or scikitlearn or scipy. 首先我得到错误: No module named xxxMissing required dependencies [xxx] ,对于pandas或numpy,或scikitlearn或scipy。

I would have expected these to be installed as part of the Visual Studio workloads, and indeed they seem to be in the Anaconda3\\Lib\\sitpackages folder, if that's where they should be. Anaconda3\\Lib\\sitpackages预计这些将作为Visual Studio工作负载的一部分安装,实际上它们似乎位于Anaconda3\\Lib\\sitpackages文件夹中,如果它们应该在那里。 But I tried installing them anyway from the Python Environments window in VS. 但我尝试从VS中的Python Environments窗口安装它们。

If I'm lucky, then I get past the above error to this one: Importing the multiarray numpy extension module failed. 如果我很幸运,那么我Importing the multiarray numpy extension module failed.上述错误: Importing the multiarray numpy extension module failed. .

Anyone got any pointers for setting this up? 任何人都有任何设置指针?

This is how I got it to work: Right click on "Python Environments" on the solution explorer window. 这就是我开始工作的方法:右键单击解决方案资源管理器窗口中的“Python环境”。 Select Add/Remove python environments and then pick an environment that has the right packages selected or add packages as needed. 选择添加/删除python环境,然后选择具有所选软件包的环境或根据需要添加软件包。

Anaconda needs to add for pandas,numpy, and pyplot. Anaconda需要添加大熊猫,numpy和pyplot。 Add Anaconda on right click on Python Environment and add the Anaconda. 右键单击Python环境添加Anaconda并添加Anaconda。

I just went through this pain the other day, on 64-bit Windows 7 with VS 2017 Community. 前几天,我在VS 2017社区的64位Windows 7上遇到了这种痛苦。

To get the regression example working I had to upgrade Python to version 3.6.1, as the pip-installed version of numpy (1.13.1) doesn't work with 3.6.0. 为了使回归示例正常工作,我必须将Python升级到版本3.6.1,因为numpy(1.13.1)的pip安装版本不适用于3.6.0。

In short, I downloaded and ran the Windows 64-bit installer for Python 3.6.1 direct from python.org, then (as you described above) from the VS Python Environments window installed matplotlib (2.0.2) numpy (1.13.1) and pandas (0.20.3). 简而言之,我从python.org直接下载并运行了Python 3.6.1的Windows 64位安装程序,然后(如上所述)从VS Python环境窗口安装了matplotlib(2.0.2)numpy(1.13.1)和熊猫(0.20.3)。 After that, all the imports worked. 之后,所有的进口都有效。 (NB it takes a while for the VS intellisense feature to get up to speed with the imports.) (注意,VS intellisense功能需要一段时间才能加快进口速度。)

On my machine pandas, numpy and matplotlib sit in 在我的机器熊猫,numpy和matplotlib坐在

C:\\Program Files\\Python36\\Lib\\site-packages C:\\ Program Files \\ Python36 \\ Lib \\ site-packages

Hope this may help. 希望这可能有所帮助。

This seems to have got it working: 这似乎已经成功:

I installed the latest version of Anaconda (after uninstalling the version that came with the Python VS workload). 我安装了最新版本的Anaconda(在卸载Python VS工作负载附带的版本之后)。

Then I installed the numpy, scipy and scikit wheels from this link . 然后我从这个链接安装了numpy,scipy和scikit轮子。 Importantly, I installed them using the Anaconda console (Start -> Anaconda Prompt [Run as Administrator]), as I had another system installation of Python, that I had been installing the wheels/packages into previously. 重要的是,我使用Anaconda控制台(开始 - > Anaconda Prompt [以管理员身份运行])安装它们,因为我有另一个Python系统安装,我之前已经安装了轮子/包。

That seemed to do the trick, after restarting Visual Studio. 在重新启动Visual Studio之后,这似乎可以解决问题。

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

相关问题 Visual Studio 2017中Windows 7的Python支持 - Python Support for Windows 7 in Visual Studio 2017 如何捆绑Python软件包(案例研究:Microsoft Visual Studio 2017) - How to bundle Python packages (case study: Microsoft Visual Studio 2017) 如何在python应用程序中的Visual Studio 2017中使用用户包 - How to use user packages in Visual Studio 2017 in a python application Visual Studio 2017-Python工具 - Visual Studio 2017 - python tool 适用于Visual Studio 2017的Python工具 - Python tool for visual studio 2017 在Visual Studio 2017中运行python - Running python in Visual Studio 2017 Python软件包在需要C源代码编译的软件包上安装失败(Visual Studio 2017) - Python package(s) install failure on packages that requires C source compiling (Visual Studio 2017) Visual Studio 代码窗口,Python Pandas。 没有名为 pandas 的模块 - Visual Studio Code windows , Python Pandas . No module named pandas Anaconda是否会重新安装所有软件包(如(numpy,pandas,pycuda等)),即使我之前在Ubuntu 18.04中使用python单独安装了它们? - Does Anaconda reinstall all the packages like(numpy, pandas, pycuda etc) even if I had installed them earlier separately with python in Ubuntu 18.04? Python工具Visual Studio 2017 RC - Python Tools Visual Studio 2017 RC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM