Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 669161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:07:15+00:00 2026-05-14T00:07:15+00:00

I have a Python file with as content: import re import urllib class A(object):

  • 0

I have a Python file with as content:

import re
import urllib

class A(object):
    def __init__(self, x):
        self.x = x

    def getVal(self):
        return self.x

    def __str__(self):
        return "instance of A with value '%s'" % (self.getVal())

I also have a simple C# console project with the following code:

engine = Python.CreateEngine();

ScriptSource source = engine.CreateScriptSourceFromFile("test.py");
ScriptScope scope = engine.CreateScope();
ObjectOperations op = engine.Operations;

source.Execute(scope); // class object created

object klaz = scope.GetVariable("A"); // get the class object
object instance = op.Call(klaz, "blabla waarde"); // create the instance
object method = op.GetMember(instance, "getVal"); // get a method

string result = (string)op.Call(method); // call method and get result (9)
Console.WriteLine("Result: " + result); //output: 'Result: blabla waarde'

(I got this from this stackoverflow querstion and answer)
If I leave out the the import urllib statement in the Python file everything works fine. (meaning it finds the re module)
But as soon as i either add import urllib or import urllib2 I get the following exception:

ImportException was unhandled
No module named urllib

So somehow it can’t find the urllib. I checked the IronPython lib folder and both urllib and urllib 2 are definitely there.
The same exception gets thrown when I import urllib in the C# code. (engine.ImportModule("urllib");)

Any ideas?
I’d like to manage the imports in the python code and not in the C# code.
(So I’d like to avoid stuff like this: engine.ImportModule("urllib");)

Edit:
Some extra info on what I’m actually going to use this for (maybe someone has an alternative):
I will have a main C# application and the python scripts will be used as extensions or plugins for the main application.
I’m using Python so that I don’t need to compile any of the plugins.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:07:15+00:00Added an answer on May 14, 2026 at 12:07 am

    I face the same problem. Following “Tom E’s” suggestion in the comments to fuzzyman’s reply I could successfully resolve the issue. The issue seems to be it is not able resolve the location of the urllib.py. We need to set it.

    You can check the following link for the question and answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this test python file import os print 'Content-type: text/html' print print '<HTML><HEAD><TITLE>Python
I have a python file that will not correctly perform an import. If I
I have a python class which reads a config file using ConfigParser: Config file:
I have a python file testHTTPAuth.py which uses module deliciousapi and is kept in
I have a python program/file that I want to run repeatedly and calculate the
I have a Visual Studio project which uses nmake to call a Python file
Let's assume I have a main script, main.py, that imports another python file with
I have a Python script that reads through a text csv file and creates
I have an existing python script that, among other things checks a file against
I just started using/learning Python and have some questions. I have a text file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.