简体   繁体   English

如何在python应用程序中的Visual Studio 2017中使用用户包

[英]How to use user packages in Visual Studio 2017 in a python application

一

I have this python application structure in Visual Studio 2017. I created a tests folder using the Solution explorer and there's a test.py file in it. 我在Visual Studio 2017中具有此python应用程序结构。我使用解决方案资源管理器创建了一个tests文件夹,其中有一个test.py文件。 I want to use the test module which is stored in tests directory. 我想使用存储在tests目录中的test模块。 But when I try to use import tests.test it says test not defined. 但是,当我尝试使用import tests.test它说test未定义。 I have just started learning python. 我刚刚开始学习python。 I looked up to this but I dont understand why isnt it working. 我抬起头, 这个可是我不明白为什么不是它的工作。 Am I doing something wrong? 难道我做错了什么? I looked it up here 在这里看了

You are trying to import from from package. 您正在尝试从包中导入。 Each package must have an __init__.py file. 每个软件包必须具有__init__.py文件。 You just have to add a blank file __init__.py to your tests folder and then it should be fine. 您只需要在tests文件夹中添加一个空白文件__init__.py ,就可以了。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM