ashishsingal
ashishsingal

Reputation: 2978

python Importing local lib instead of builtin

I forked pandas in order to make a few changes. However, Python is importing the Anaconda builtin pandas instead of mine. Here's the directory structure ..

/Untitled2.ipynb > file I'm working on
/pandas/ > local Python code

In /Untitled2.ipynb, I have ..

from pandas import pandas

Then running

pandas?

returns

Type:        module
String form: <module 'pandas' from 'C:\\Anaconda3\\lib\\
site-packages\\pandas\\__init__.py'>
File:        c:\anaconda3\lib\site-packages\pandas\__init__.py

I want the module to import from /pandas/pandas instead. How can I do this?

Upvotes: 1

Views: 105

Answers (2)

Skycc
Skycc

Reputation: 3555

Insert local pandas path to top of sys.path

sys.path.insert(0, r'/path_to_pandas')

Upvotes: 1

samwyse
samwyse

Reputation: 2996

Check sys.path and insure that '/' (or whereever pandas is installed) appears before 'c:\anaconda3\lib\site-packages'.

Upvotes: 0

Related Questions