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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:16:38+00:00 2026-06-03T10:16:38+00:00

The function below based on the Python sample code in the Python gzip module

  • 0

The function below based on the Python sample code in the Python gzip module docs. It runs reliably on Ubuntu 10.04 with its default Python 2.6.x. On Ubuntu 11.04, however, the code fails @ writelines().

On one 11.04 machine, the failure message reported 'module' object has no attribute 'BufferedIOBase'. Another 11.04 machine reported a different message No module named numpy. Yet, the numpy package is installed on both machines.

Does anyone know of any missing Python dependencies or other problems on 11.04 that would cause this?

def _compress(inp,out):
    import gzip
    f_out = gzip.open(out,'wb')
    f_in = open(inp,'rb')
    f_out.writelines(f_in)
    f_out.close()
    f_in.close()
    os.unlink(inp)
  • 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-06-03T10:16:39+00:00Added an answer on June 3, 2026 at 10:16 am

    The error message No module named numpy is unrelated to this problem; some other bug is causing this. To track this down, print the value of sys.path to see which paths Python would search for a module. Numpy might be installed but maybe not in a place included in sys.path. That out of the way, back to your main issue.

    1. Check the Python version. My guess is that 11.04 comes with 2.7.x.

    2. writelines() is an odd method to call for binary data. Even worse, the parameter should be a sequence of strings, not a file object. Try this code instead:

      f_out.write( f_in.read() )
      
    3. Depending on the file size, this eats a lot of memory. Try a loop instead:

      while True:
          data = f_in.read( 10240 )
          if not data: break
          f_out.write( data )
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the function below to open the user's default web browser. Public
Based on the function below, it is used to load data from file .dat.
Can anyone help with what is wrong in the code below(based on the answers
I have written code for threading in Python. It throws the error below. How
With the below function is based on the 0MQ Haskell bindings. I get an
My function below, will take the values from my custom meta fields (after a
My function below calls a partial view after a user enters a filter-by string
I am using the function below inside a thread to receive the byte[] via
I have written a function below: void trans(double x,double y,double theta,double m,double n) {
I have the following function below: public function setupHead($title){ $displayHead .='<!DOCTYPE html PUBLIC -//W3C//DTD

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.