add python3 library to python3.6 path

1.2k views Asked by At

hello I'm new to python3 and python3.6, I usually use pip3 install to add old libraries to my python3 path.

I recently picked up python3.6 for managing my home servers with its asyncio functionalities however my python3.6 interpreter is unable to locate pwnlibs and am thus unable to reuse my old code.

I tried:

import sys
import os
sys.path.append(os.path.abspath(pwn.__file__))
import pwn

debugging results:

on python3.4 os.path.abspath(pwn.__file__) returns the correct path to the library

1

There are 1 answers

0
Erik On

While sys.path.append is a valid means to add to your python path at runtime, you can't get the path from a module you have not yet loaded.

Instead you should install your packages using pip3 or in a specific location and add that to your path either at runtime or via the PYTHONPATH environment variable.

I would guess since you mentioned pip3 already however that you had the pwn package already installed when you tried with 3.4 and your install of Python 3.6 is not using the same paths as your Python 3.4 install. Try comparing your python paths from 3.4 with 3.6 by comparing the output from sys.path.

Lastly, just as a note, if you are using the pwntools package, it doesn't yet support Python 3, so if you are simply copying the folder, be aware it might not function correctly or at all.