I am working on a webapplication in .net using razor pages in the mvvm-model. I've written a crawler/parser in Python that I need to control from my .NET-project. So I found another stackoverflow post that helps me solve this issue.
In order to keep my Python environment clean and organized, I've used a virtualenv to keep my libraries (BeautifulSoup4
and Requests
) separated from my global interpreter. This all worked out the way I wanted.
However, I have reached a point where I need to connect both applications. So I put me parser in a separated folder within my .NET project. Furthermore, whenever my form is validated etc and reaches my OnPostAsync
-method, it starts a process just like the above mentioned post describes.
But when I hit the submit button I can see in my console it is unable to find the correct packages in my Python application, since I am getting the famous: ImportError: No module named 'bs4'
. I am aware this error is known and widely answered before, but I have a different question.
Question
I'd like to know how I fix this error with respect to my .NET-project and the virualenv. So i.e., is there a way to use or to link my virtualenv from Python in my .NET-project?
My Python-project-structure is:
/app/
/src/ <-- Source code
/output/ <-- Not relevant
/tests/ <-- Not relevant
/venv/ <-- Installed libraries
main.py <-- Entrypoint application