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

  • Home
  • SEARCH
  • 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 368239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:48:18+00:00 2026-05-12T13:48:18+00:00

I am embedding IronPython in a C# program. I understand that I need to

  • 0

I am embedding IronPython in a C# program. I understand that I need to call ScriptEngine.SetSearchPaths with a list of search paths so that my Python code can import modules. In particular I have to let it know where the standard library modules are, which in my case are here:

C:\Program Files (x86)\IronPython 2.0.2\Lib

My question is, how can that path be found programatically?

It evidently can be done because the IronPython Console knows about it:

>>> import sys
>>> sys.path
['C:\\Windows\\system32', 'C:\\Program Files (x86)\\IronPython 2.0.2\\Lib', 'C:\\Program Files (x86)\\IronPython 2.0.2', 'C:\\Program Files (x86)\\IronPython 2.0.2\\lib\\site-packages'] 
  • 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-12T13:48:18+00:00Added an answer on May 12, 2026 at 1:48 pm

    A possible solution would be to ship a copy of the Lib folder with your application. I believe that both the IronPython license (Microsoft Public License (Ms-PL)) and the Python license (Python License) will permit this.

    Benefits to this plan:

    1. It will be easy for the app to find the Lib folder.

    2. Installation will be easier since there will be one less installer to deal with.

    3. The total size of the installer will be smaller.

    4. If the IronPython assemblies that the app uses are copied locally, then it makes sense to copy Lib too, so that the two won’t get out of sync as they might do if the Lib from Program Files were used.

    The licenses don’t appear to impose any onerous obligations. The Ms-PL does requires that you include a complete copy of the Ms-PL in the distributions, but that is not a big deal.

    Edit : Here’s the code

    The following is what I did.

    The Lib folder is copied in the AfterBuild target of my .csproj file. I couldn’t work out how to use the built-in MSBuild copy command because everything to do with MSBuild is designed to maximally painful, so I used robocopy instead. (robocopy is the replacement of xcopy; you could used xcopy instead).

    <Target Name="AfterBuild">
      <Exec Command="robocopy $(ProjectDir)..\3rdParty\IronPython\IronPython2.0.2\Lib $(OutputPath)IronPython\Lib /E /XD .svn" IgnoreExitCode="true" />
      <Exec Command="copy $(ProjectDir)..\3rdParty\IronPython\IronPython2.0.2\license.* $(OutputPath)IronPython\" />
    </Target>
    

    It copies the license files (as required by the license) and it excludes subversion folders (.svn).

    The “3rdParty” folder is at the root level of my Visual Studio solution. It’s where I keep third party libraries.

    I ignore the exit code for robocopy because <Exec> can’t deal with robocopy’s exit codes. This is not ideal, but I assume that the plain copy in the next line will pick up any problems.

    This is how I find the Lib path in code:

    var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    var libPath = Path.Combine(assemblyPath, @"IronPython\Lib");
    

    To copy Lib in a unit test, do something like this:

    [TestMethod()]
    [DeploymentItem(@"3rdParty\IronPython\IronPython2.0.2\Lib", @"IronPython\Lib")]
    public void MyTest()
    {
        // ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Your Question title says you want to access gmail emails… May 12, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer you should take a look in LZMA SDK, it would… May 12, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer just try this code while(st.hasMoreTokens()) { if(count==1) { e.ename=st.nextToken(); count++;… May 12, 2026 at 10:12 pm

Related Questions

[This question is similar to this one , but I am also interested in
I'm embedding IronPython in my C# application. For some reason I'm having trouble loading
I am embedding a windows application into my SWT application using 'reparenting'. That part
I am embedding a report into my ASP.NET app using the report viewer control.

Trending Tags

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

Top Members

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.