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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:09:00+00:00 2026-05-26T15:09:00+00:00

See update at the end. I am using Ubuntu Linux 11.10, Python 3. I

  • 0

See update at the end.

I am using Ubuntu Linux 11.10, Python 3.

I wrote a Python script which converts some Qt *.ui files to *.py using pyuic4. Then i want to compile the obtained *.py file to *.pyc and delete the *.py file.

For some reason when i delete a converted *.py file, the *.pyc version is also deleted:

try:
    command = 'pyuic4 -o /home/vic/ui_form.py /home/vic/form.ui'
    output = subprocess.check_output(command, shell= True, stderr= subprocess.STDOUT)
except subprocess.CalledProcessError as e:
    print('Failed:', e.output)
else:
    print('Converted %s to %s' % (source, targetName))

# convert *.py to *.pyc and delete the source
source = '/home/vic/ui_form.py'
target = source + 'c' # py -> pyc
py_compile.compile(source, target)
#shutil.copy(target, target + '_') # if uncommented - the *.pyc_ file remains
os.remove(source) # if commented - both *.py and *.pyc files remain, otherwise both deleted (?)

I don’t know what’s happening (see the comments in the code for additional info).

I thought i would have a hint if i find WHO deletes the file – maybe it’s pyuic4?

I there a possibility to monitor which process deletes a file?


UPDATE:

I was debugging step by step. After executing os.remove(source) both files (*.py – source, and *.pyc) are deleted.

Could this be some Python behavior?

  • 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-26T15:09:00+00:00Added an answer on May 26, 2026 at 3:09 pm

    I was going crazy all the day with this issue, and, as it often happens, the solution was near, but of a different kind:

    I have this project open in Eclipse. When Eclipse is open it tracks the creation of new *.py files (from *.ui or *qrc). Then Eclipse automatically adds them to the project.

    When the script converts *.py files to *.pyc and deletes the *.py files – Eclipse also tracks this and carefully deletes the corresponding *.pyc files.

    So this is it.

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

Sidebar

Related Questions

Update: After some more reading I see that this problem is totally general, you
I am having problems using the update method of scala.collection.immutable.HashMap.I don't see the reason
I have a JAX-B java web service which I'm using to update a database.
I want to update a row which has some html tags inside. For instance:
I have a form which I am using to update an existing set of
[See update at the end] I'm working with Zend framework, in PHP and I
Update: See the bottom of this question for a C# workaround. Hi there, Consider
I see that EF can update a model based on an existing database schema.
Update: OK I see it's a bubble sort, but is it less efficient because
Update: Solved, with code I got it working, see my answer below for the

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.