# Python 2 compatible with Python 3

**URL:** <https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241>\
**Category:** Coding\
**Created:** [April 1, 2019, 7:22pm UTC](https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241 "2019-04-01T19:22:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hgill16](https://avatars.discourse-cdn.com/v4/letter/h/34f0e0/32.png) [@hgill16](https://discourse.psychopy.org/u/hgill16)\
**Post date:** [April 1, 2019, 7:22pm UTC](https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241/1 "2019-04-01T19:22:34Z")

</div>

Hello,

I am needing help with writing a code that will make my task that was built in python 3 compatible with python version 2. The computer the task will be run on only has python 2 and can not be changed to python 3.

---

<div class="post-metadata">

**Author:** ![hgill16](https://avatars.discourse-cdn.com/v4/letter/h/34f0e0/32.png) [@hgill16](https://discourse.psychopy.org/u/hgill16)\
**Post date:** [April 2, 2019, 4:47pm UTC](https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241/3 "2019-04-02T16:47:14Z")

</div>

I am unfamiliar with _future_ would you be able to explain how that works?

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [April 2, 2019, 4:54pm UTC](https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241/4 "2019-04-02T16:54:27Z")

</div>

I’m sorry. I misread the question. The future module helps you to use py3 functionality in py2, but it doesn’t convert your code.

You may be interested in:  
[https://wiki.python.org/moin/3to2](https://wiki.python.org/moin/3to2)

---

<div class="post-metadata">

**Author:** ![hgill16](https://avatars.discourse-cdn.com/v4/letter/h/34f0e0/32.png) [@hgill16](https://discourse.psychopy.org/u/hgill16)\
**Post date:** [April 2, 2019, 5:07pm UTC](https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241/5 "2019-04-02T17:07:05Z")

</div>

Is there a line of code that I can put before my task starts in order to make it compatible with version 3?

---

<div class="post-metadata">

**Author:** ![LukasPsy](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/lukaspsy/32/4582_2.png) [@LukasPsy](https://discourse.psychopy.org/u/LukasPsy)\
**Post date:** [April 2, 2019, 7:46pm UTC](https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241/6 "2019-04-02T19:46:47Z")

</div>

Not that I know of.

On [this site](https://stackoverflow.com/questions/14804287/running-py3to2-using-windows-7) there is advice on how to convert scripts from py3 to py2:

"Do you know how to use pip?

Just type in `C:/[Enter your python folder]/Scripts/pip install 3to2`

Go to the Scripts folder in the Python folder and rename `3to2` to `3to2.py`

Then, type in `C:/[Enter python folder again]/python.exe C:/[Enter python folder]/Scripts/3to2.py -w Path/To/The/Python/File`"

---

<div class="post-metadata">

**Author:** ![hgill16](https://avatars.discourse-cdn.com/v4/letter/h/34f0e0/32.png) [@hgill16](https://discourse.psychopy.org/u/hgill16)\
**Post date:** [April 2, 2019, 8:48pm UTC](https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241/7 "2019-04-02T20:48:08Z")

</div>

I do not know how to use pip

This is what I am typing into the python command window and it comes back invalid. I have tried other variations of this code too, but it is not working.

C:/[Users\EEG\Python]/Scripts/pip install 3to2

The python folder is just the pathway right?

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [April 3, 2019, 12:16am UTC](https://discourse.psychopy.org/t/python-2-compatible-with-python-3/7241/8 "2019-04-03T00:16:13Z")

</div>

Can you not just install the standalone version of PsychoPy (version 3 if you like), and ignore the issue of what Python version is installed on the computer? i.e. standalone PsychoPy has its own bundled version of Python, precisely so you don’t have to worry about things like this.
