Issue with beautifulsoup 4

Hey Everyone, I'm running into an issue importing beautifulsoup 4 only if I import clr before importing beautifulsoup. I'm using python 3.5 32-bit version on my Windows 7 and Windows 10 box. I'm using beautifulsoup package from Gohlke website (beautifulsoup4-4.4.1-py3-none-any.whl) I simply runimport clrfrom bs4 import beautifulsoup then I get this error Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) I build the pythonnet debug version I get this call stack Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) in pythonnet\src\runtime\moduleobject.cs:line 26 at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) in pythonnet\src\runtime\moduleobject.cs:line 101 at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 315 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237 if I switch the lines of codefrom bs4 import Beautifulsoupimport clr no errors occur. Is anyone running into this issue? Thanks. Danny

There is pending pull request hopefully addressing this issue: https://github.com/pythonnet/pythonnet/pull/219 If not, then please open an issue on github or comment on that pull request. On Friday, May 27, 2016, Daniel Fernandez <fernandez_dan2@hotmail.com> wrote:
Hey Everyone,
I'm running into an issue importing beautifulsoup 4 only if I import clr before importing beautifulsoup. I'm using python 3.5 32-bit version on my Windows 7 and Windows 10 box. I'm using beautifulsoup package from Gohlke website (beautifulsoup4-4.4.1-py3-none-any.whl)
I simply run import clr from bs4 import beautifulsoup
then I get this error
Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw)
I build the pythonnet debug version I get this call stack
Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) in pythonnet\src\runtime\moduleobject.cs:line 26 at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) in pythonnet\src\runtime\moduleobject.cs:line 101 at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 315 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237
if I switch the lines of code from bs4 import Beautifulsoup import clr
no errors occur. Is anyone running into this issue?
Thanks.
Danny

Hi Denis, I just verified that this does fix the issue with the local import in this specific case. Any idea when the pull request will be accepted? Danny Date: Sat, 28 May 2016 11:55:28 -0500 From: denis.akhiyarov@gmail.com To: pythondotnet@python.org Subject: Re: [Python.NET] Issue with beautifulsoup 4 There is pending pull request hopefully addressing this issue: https://github.com/pythonnet/pythonnet/pull/219 If not, then please open an issue on github or comment on that pull request. On Friday, May 27, 2016, Daniel Fernandez <fernandez_dan2@hotmail.com> wrote: Hey Everyone, I'm running into an issue importing beautifulsoup 4 only if I import clr before importing beautifulsoup. I'm using python 3.5 32-bit version on my Windows 7 and Windows 10 box. I'm using beautifulsoup package from Gohlke website (beautifulsoup4-4.4.1-py3-none-any.whl) I simply runimport clrfrom bs4 import beautifulsoup then I get this error Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) I build the pythonnet debug version I get this call stack Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) in pythonnet\src\runtime\moduleobject.cs:line 26 at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) in pythonnet\src\runtime\moduleobject.cs:line 101 at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 315 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237 if I switch the lines of codefrom bs4 import Beautifulsoupimport clr no errors occur. Is anyone running into this issue? Thanks. Danny _________________________________________________ Python.NET mailing list - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet

Hi Danny, I'm aware of few things that prevent merging this pull request at current state: 1. [VERY SIMPLE FIX] c# 6 syntax was used in this pull request, but should be downgraded to c# 4 due to .NET 4.0 and Mono. This can be re-considered if someone is willing to look into this closer. 2. Writing unit tests for this pull request. 3. De-couple the fix for build script from this pull request. Appveyor builds and tests were failing before, but seem to be working now. If anyone is willing to finish off this pull request, then the author seems to be fine: https://github.com/pythonnet/pythonnet/pull/219#issuecomment-222077108 Thanks, Denis On Sun, May 29, 2016 at 10:34 AM, Daniel Fernandez < fernandez_dan2@hotmail.com> wrote:
Hi Denis,
I just verified that this does fix the issue with the local import in this specific case. Any idea when the pull request will be accepted?
Danny ------------------------------ Date: Sat, 28 May 2016 11:55:28 -0500 From: denis.akhiyarov@gmail.com To: pythondotnet@python.org Subject: Re: [Python.NET] Issue with beautifulsoup 4
There is pending pull request hopefully addressing this issue:
https://github.com/pythonnet/pythonnet/pull/219
If not, then please open an issue on github or comment on that pull request.
On Friday, May 27, 2016, Daniel Fernandez <fernandez_dan2@hotmail.com> wrote:
Hey Everyone,
I'm running into an issue importing beautifulsoup 4 only if I import clr before importing beautifulsoup. I'm using python 3.5 32-bit version on my Windows 7 and Windows 10 box. I'm using beautifulsoup package from Gohlke website (beautifulsoup4-4.4.1-py3-none-any.whl)
I simply run import clr from bs4 import beautifulsoup
then I get this error
Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw)
I build the pythonnet debug version I get this call stack
Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) in pythonnet\src\runtime\moduleobject.cs:line 26 at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) in pythonnet\src\runtime\moduleobject.cs:line 101 at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 315 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237
if I switch the lines of code from bs4 import Beautifulsoup import clr
no errors occur. Is anyone running into this issue?
Thanks.
Danny
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet

Hi All, I narrow down the issue to a relative import of html5lib. I see there is already a pull request (https://github.com/pythonnet/pythonnet/pull/219) that addresses this relative import issue chaning the importhook.cs. Thanks. Danny From: fernandez_dan2@hotmail.com To: pythondotnet@python.org Date: Fri, 27 May 2016 22:02:14 -0600 Subject: [Python.NET] Issue with beautifulsoup 4 Hey Everyone, I'm running into an issue importing beautifulsoup 4 only if I import clr before importing beautifulsoup. I'm using python 3.5 32-bit version on my Windows 7 and Windows 10 box. I'm using beautifulsoup package from Gohlke website (beautifulsoup4-4.4.1-py3-none-any.whl) I simply runimport clrfrom bs4 import beautifulsoup then I get this error Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) I build the pythonnet debug version I get this call stack Unhandled Exception: System.ArgumentException: Name must not be empty! at Python.Runtime.ModuleObject..ctor(String name) in pythonnet\src\runtime\moduleobject.cs:line 26 at Python.Runtime.ModuleObject.GetAttribute(String name, Boolean guess) in pythonnet\src\runtime\moduleobject.cs:line 101 at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 315 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237 at Python.Runtime.Runtime.PyObject_Call(IntPtr pointer, IntPtr args, IntPtr kw) at Python.Runtime.ImportHook.__import__(IntPtr self, IntPtr args, IntPtr kw) in pythonnet\src\runtime\importhook.cs:line 237 if I switch the lines of codefrom bs4 import Beautifulsoupimport clr no errors occur. Is anyone running into this issue? Thanks. Danny _________________________________________________ Python.NET mailing list - PythonDotNet@python.org https://mail.python.org/mailman/listinfo/pythondotnet
participants (2)
-
Daniel Fernandez
-
Denis Akhiyarov