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 7417949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:47:43+00:00 2026-05-29T07:47:43+00:00

I am able to create Python scripts and dynamically run them via Visual Studio

  • 0

I am able to create Python scripts and dynamically run them via Visual Studio / .NET 4.0 like this:

# testScript.py file:
import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7.1\Lib')
import os
os.environ['HTTP_PROXY'] = "127.0.0.1:8888"
import urllib2
response = urllib2.urlopen("http://www.google.com")

then in a .NET 4.0 WinForms project:

ScriptEngine engine = Python.CreateEngine();
ScriptSource script = engine.CreateScriptSourceFromFile("testScript.py");
ScriptScope scope = engine.CreateScope();
script.Execute(scope);

However, the IronPython DLLs that I import don’t contain all the standard modules and so I have to do the

import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7.1\Lib')

step so that I can run the next 4 lines.

Is there some way I can avoid this?

I’m going to be publishing the application and I don’t want to have to rely on the file path being the same on everyone’s machine!

  • 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-29T07:47:43+00:00Added an answer on May 29, 2026 at 7:47 am

    There’s an extension method that allows you to do this directly:

    ScriptEngine engine = Python.CreateEngine();
    ScriptSource script = engine.CreateScriptSourceFromFile("testScript.py");
    ScriptScope scope = engine.CreateScope();
    
    engine.SetSearchPaths(new string[] { "C:\\Program Files (x86)\\IronPython 2.7.1\\Lib" });
    script.Execute(scope);
    

    It’s probably best to include the stdlib with your app in a private directory rather than rely on it being installed, but that’s up to you.

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

Sidebar

Related Questions

In Python, I'd like to be able to create a function that behaves both
I have been given a task to create a Python file that will take
I'm using python with matplotlib to create plots out of data, an I'd like
You should be able to create a generic form: public partial class MyGenericForm<T> :
Has anyone been able to create Container-Specific Master Pages for Safari or Chrome? I
I am able to create and execute a DTS package that copies tables from
I have been able to create ASPX pages without the code behind, but I
I am able to create a UIImage from a Core Animation layer using the
I am able to create a connection to a local sqlite3 database ( Using
I am able to create alternate dictation grammars using the dictation resource kit or

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.