Skip to content Skip to sidebar Skip to footer

Using Packages By Providing Sys Path

I came across this link: (Python) Use a library locally instead of installing it And followed the steps to provide path to IBPy package which I downloaded and extracted on my deskt

Solution 1:

Use raw strings for Windows paths. The \b is being interpreted as a backspace character.

r'C:\Users\Duck\Desktop\IbPy-0.7.6-9.51\build\lib\ib'

should work. Raw strings prevent the interpretation of backslash escapes for all but the string's quote character.

Solution 2:

The package is the shallowest directory with an __init__.py and that directory name is the package name. sys.path needs to include the directory before the package directory because python will append the package name to the names in sys.path until it finds a match. Since the directory ib holds the package __init__.py you need to

import sys
sys.path.append(r'C:\Users\Duck\Desktop\IbPy-0.7.6-9.51\build\lib')
import ib

Post a Comment for "Using Packages By Providing Sys Path"