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

Ask A Question

Stats

  • Questions 493k
  • Answers 493k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to use urlencode to encode the parameter data--something… May 16, 2026 at 10:37 am
  • Editorial Team
    Editorial Team added an answer Found it: Bug Changelog of fix Apparently fixed in 2.5.2.… May 16, 2026 at 10:37 am
  • Editorial Team
    Editorial Team added an answer I would use simple concatenation: Char.ToLowerInvariant(name[0]) + name.Substring(1) The first… May 16, 2026 at 10:37 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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 script which should parse a file and produce some output
While I have been playing with Python for a few months now (just a
i dont have any experience in python programming but I get to run python
I'm trying to use the python-daemon module. It supplies the daemon.DaemonContext class to properly
I'd like to extract the text from an HTML file using Python. I want
I have a general purpose file storage backed by Google App Engine Blobstore, when
I have a simple python script that just takes in a filename, and spits
Which is better for creating a settings file for Python programs, the built-in module
I'm writing a python script to read through a list of domains, find out

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.