Running external package in Python

A forum for general discussion of the Python programming language.

Running external package in Python

Postby gladaki » Tue Jan 14, 2014 8:27 pm

Hi All !
I am a beginner in python. I just installed a external packge in python 2.7 with so when i type help(package1) i can see its help and installed
But i am not able to use the functions in that package..can some one help me with it. Following are my questions
1. This is how my directory look like packag1>A B C D
so my looks like
Code: Select all
import A
import B
import C
import D

__all__=["A", "B", "C", "D"]

now when i go in directort A , I have three files has many functions one of them is def oa(a,b,c,d,e)...and in i can there is import oa with other functions..

Now my question
1.What is file
2.How can i use function oa...
I tried using import Package1
oa(1,2,3,4,5) but it says oa is not defined...I already installed the package in python then why its not recognzing the function
Last edited by stranac on Tue Jan 14, 2014 8:30 pm, edited 1 time in total.
Posts: 1
Joined: Tue Jan 14, 2014 8:16 pm

Re: Running external package in Python

Postby tnknepp » Tue Jan 14, 2014 9:10 pm

Do one of the following instead:

Code: Select all
import reflection

# OR
from reflection import * # usually not favored for some reason

Python: 2.7 via Anaconda
Numpy: 1.7
Pandas: 0.11
OS: Windows 7
IDE: Spyder/IPython
User avatar
Posts: 153
Joined: Mon Mar 11, 2013 7:41 pm

Re: Running external package in Python

Postby ochichinyezaboombwa » Tue Jan 14, 2014 10:59 pm

You don't need to change your working directory in order for import to succeed.
a) if you install standard libraries the installation process takes care of everything; just "include your_module" should work from everywhere;
b) if you import your own libraries (modules), you need to have the env. variable PYTHONPATH set properly (read about it) and in each of your directories.
Posts: 203
Joined: Tue Jun 04, 2013 7:53 pm

Return to General Discussions

Who is online

Users browsing this forum: No registered users and 4 guests