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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:34:26+00:00 2026-05-22T02:34:26+00:00

I have two Python classes written in two different files. One is written in

  • 0

I have two Python classes written in two different files. One is written in Python 2.7 and the other written in Python 3.2. One class is used inside the other.

Is it possible to run both of them so that one class will use the 3.2 interpreter and the other will use the 2.7 interpreter?

For instance in the terminal, can I just run the following command?

python3.2 firstClass.py

Any suggestions?

Thanks

  • 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-22T02:34:27+00:00Added an answer on May 22, 2026 at 2:34 am

    I don’t believe it is possible for them to be running in the same process, that is you will have to choose one or the other. Python3 and Python2 bytecode are not compatible with each other, which you can confirm by attempting to run Python2 bytecode in Python3:

    % cat > test.py
    a = 1
    % python2.6 -m compileall .
    % python2.6 test.pyc
    % python3.1 test.pyc
    RuntimeError: Bad magic number in .pyc file
    

    Try something more complicated to be sure. Compile test.py using Python2 and then remove the .py file to make sure it isn’t recompiled by Python3. Then, attempt to import the .pyc bytecode into a Python3 interpreter.

    % python2.6 -m compileall .
    % rm test.py
    % cat > test2.py
    import test
    print(test.a)
    % python2.6 test2.py
    1
    % python3.1 test2.py
    Traceback (most recent call last):
      File "test2.py", line 1, in <module>
        import test
    ImportError: Bad magic number in test.pyc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two classes, and want to include a static instance of one class
I have two classes in python Drunk Usual Drunk The usual drunk class inherits
Basically I have written two modules for my Python Program. I need one module
Possible Duplicate: comparing contents of two files using python I have a file name
I have two String.printable mysteries in the one question. First, in Python 2.6: >>>
I have two applications written in Java that communicate with each other using XML
I have two files: choices.py class SomeChoice: name = ulorem class AnotherChoice: name =
I have two classes that refer to each other, but obviously the compiler complains.
Ok I have two modules, each containing a class, the problem is their classes
I have two python scripts. First one is just a script waiting for user

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.