问题描述
我是Python的新手,我正在尝试使用IronPython在Visual Studio CE 2015上编写我的第一个Python应用程序.
I'm new at Python, and I'm trying to write my first Python application on Visual Studio CE 2015 using IronPython.
我最终设法执行了最基本的.NET兼容代码,导入了clr
模块(该模块随附了整个IronPython软件包),但是,由于我的目标是编写一个应用程序,因此在,我在尝试导入usb
模块.
I finally managed to execute the most basic .NET-compatible code importing the clr
module (which comes with the whole IronPython package) but, since my goal is writing an application that reads from a USB scale following this blog post, I'm stuck at trying to import the usb
module.
我下载并安装了pyUSB和libusb,因此我想像其他任何普通的.NET应用程序一样,只需在引用"部分中添加引用,但是找不到引用或DLL文件路径.缺少的链接是什么?
I downloaded and installed both pyUSB and libusb, so I thought I had to simply add the reference in the "reference" section like any other normal .NET applications, but I can't find nor the reference nor the DLL file path. What's the missing link??
import clr
clr.AddReferenceToFileAndPath(r"What\Is\The\Path\Going\Here?")
import usb.core
推荐答案
感谢@Xaerxess,我终于明白python库只是在编译器目录中找到的.py文件.我将usb目录复制到了编译器的lib目录下,并且可以正常工作.
Thanks to @Xaerxess, I finally understand python libraries are just .py files that are to be found in the compiler directory. I copied the usb directory under the compiler's lib directory and it worked.
这篇关于使用Visual Studio引用IronPython中的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!