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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T22:10:14+00:00 2026-05-24T22:10:14+00:00

I use subprocess.Popen in one of the my views: path = os.path.join(os.path.dirname(__file__), ‘foo/bar.py’) subprocess.Popen([python,path])

  • 0

I use subprocess.Popen in one of the my views:

path = os.path.join(os.path.dirname(__file__), 'foo/bar.py')
subprocess.Popen(["python",path])

In my wsgi file, I have

import os
import sys

ppath = '/home/socialsense/ss/src'
if ppath not in sys.path:
        sys.path.append(ppath)

os.environ['DJANGO_SETTINGS_MODULE'] = 'ss.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

and under src i have ss, my django project.

But when I check my log file, bar.py encountered an error, ImportError: No module named ss.discovery.models. Now it seems that the module ss itself is not in sys.path when using Popen…

anything i did wrongly here?

  • 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-24T22:10:14+00:00Added an answer on May 24, 2026 at 10:10 pm

    It will only be in sys.path for the current Python instance. To get it for another, use the env argument to Popen with os.pathsep:

    import subprocess
    import os
    import sys
    subprocess.Popen(["python",path], env = {'PYTHONPATH': os.pathsep.join(sys.path)})
    

    You should really look into the multiprocessing module for running multiple instances of Python.

    Edit: @Graham pointed out in a comment that you might want to run this external script with a different version of Python than the one you’re calling it from. That sounds unlikely to me, but if so, you’d need most of PYTHONPATH to be different for it to work, so you’d need to just add /home/socialsense/ss/src.

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

Sidebar

Related Questions

can I use Popen from python subprocess to close started process? For example, from
As is asked in this post , I can use Python's subprocess.Popen() function to
I'm trying to use subprocess.Popen to construct a sequence to grab the duration of
I learned that when executing commands in Python, I should use subprocess. What I'm
I'm attempting to use the python subprocess module to log in to a secure
I'm currently using os.popen() but have been recommended to use subprocess.popen() instead. Any ideas
I'm working on a simple Python script that can use subprocess and/or os to
I'm using python 2.6.4 and discovered that I can't use gzip with subprocess the
Update: When I use the subprocess.call instead of subprocess.Popen , the problem is solved
I am trying to use th subprocess module along with the Popen class to

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.