New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
命名不规范导致在使用ipdb进行debug时报错 #133
Comments
profile属于python内置模块,不应该以内置模块作为目录名。 |
您在导入 profile 模块时,可以使用 as 别名来避免命名冲突。 |
我们在使用其他包的时候,包里面调用了系统的profile,所以导致不能和阿里云这个包同时使用。 |
您好,Python规范并未禁止在顶级命名空间不同的情况下,存在2个相同的包名。对于您遇到的问题,我们建议避免使用相对引用(例如 from . import profile),避免在 aliyunsdkcore 路径下启动您的程序,来防止系统的profile模块和 aliyunsdkcore.profile模块冲突。 如果以上的信息未能解决您的问题,请您提供一下截图、具体报错信息等来让我们知道问题的细节以及如何重现。谢谢! |
在django中接入了core SDK,用做滑块验证码的相关逻辑。 然后在django中,比如某个views中,使用ipdb打断点调试的时候,就会报错。 代码如下: 首先我写了一个utils.py,用来存公用的东西,比如发短信,滑块验证码,其中有一段这样的代码: 然后在任何一个views.py里面引入ipdb,django就会报错,无法runserver起来。 如果在重写的get方法里面引入,当请求执行到get方法时,就会报错。 随后我使用pdb,进行调试,打印了一下profile,发现引入的不是python自带的,而是sdk下的。 总结一下,大概意思就是在django下(其他的也有可能,未测试),用这个包,就会覆盖python自带的profile, 如果其他依赖的包引入了profile模块,并使用, 就会报错。 |
您是否还有问题?如果没反馈我们将在3天内关闭,如有疑问请重新打开。 |
所以问题的解决方案是啥? |
该目录以profile命名:https://github.com/aliyun/aliyun-openapi-python-sdk/tree/master/aliyun-python-sdk-core/aliyunsdkcore/profile
在我们公司的django项目中引入了aliyun-openapi-python-sdk。
随后在django中使用ipdb进行debug,设置断点就会报错。
经过查证是因为ipdb中这个profile和python内置的profile冲突了。
如果可以,希望能修改一下该包里面的profile命名。
The text was updated successfully, but these errors were encountered: