473,386 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Import - interpreter works but .py import does not

First post and very much a newbie to Python. Have 2.5 on Linux (GG). I
think I have set up PYTHONPATH correctly in that I can import a module
apply_bp and it complains about line 20 in apply_bp which is:

import sys, aipy, numpy, os

At the interpreter prompt, however, I can import sys, numpy etc. and
can do dir() and see the entry points so I think my overall
installation is OK.

Why does line not work ? Also I would have thought that when I pre-
imported sys et al that they would be in the symbol table so that the
import line would be a noop.

Thanks,

Slainte,

John
Mar 10 '08 #1
1 1816
On Mar 10, 1:59 pm, John Boy <sla1nte2...@yahoo.comwrote:
First post and very much a newbie to Python. Have 2.5 on Linux (GG). I
think I have set up PYTHONPATH correctly in that I can import a module
apply_bp and it complains about line 20 in apply_bp which is:

import sys, aipy, numpy, os
Please get used to showing the error message. "it complains about line
x" is not very helpful. Fortunately in this case we can guess that it
is "complaining" about inability to import either aipy or numpy (sys
and os are built-in).
>
At the interpreter prompt, however, I can import sys, numpy etc. and
can do dir() and see the entry points so I think my overall
installation is OK.

Why does line not work ?
More information please.

At the interpreter prompt, do this:
import sys
sys.path
import aipy; aipy.__file__
import numpy; numpy.__file__
and show us the result.
Change the offending line in your apply_bp module to
import sys
print sys.path
import os, aipy, numpy
and show us ALL of the output.
At the shell prompt, do whatever it takes to display the contents of
PYTHONPATH, and show us the results.
Also I would have thought that when I pre-
imported sys et al that they would be in the symbol table so that the
import line would be a noop.
The concept of "preimporting" a module is novel to me. Importing a
module at the interpreter prompt doesn't persist when you exit the
interpreter and then (implicitly) start up another interpreter task to
run your script. Importing a module in your script puts the module in
the script's namespace, which is quite distinct from the namespace of
the apply_bp (or any other) module. If those two possibilities don't
cover what you mean, please explain.
Mar 10 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Colin Brown | last post by:
I have instances where Python 2.3.2 import both does not work or error. It can be demonstrated under Win2k and Linux by doing the following: 1. Create a subdirectory "abc" 2. In directory "abc"...
0
by: Vio | last post by:
Hi, I've been trying to embed (statically) wxPy alongside an embedded py interpreter on a linux/gtk box. At one point, for some reason misc.o linking reported "multiple definitions of...
2
by: Wolfgang.Stoecher | last post by:
Hi, another beginner's question: when I import a module, change the corresponding textfile and try to import the same module again, it looks like the internal code does not change (the...
3
by: Olivier Noblanc ATOUSOFT | last post by:
Hello, When i want to import a .py fire from another subdirectory i make import inc/setupxml but that make me an error message.
0
by: Bill Davy | last post by:
I am working with MSVC6 on Windows XP. I have created an MSVC project called SHIP I have a file SHIP.i with "%module SHIP" as the first line (file is below). I run SHIP.i through SWIG 1.3.24...
11
by: Mark | last post by:
Hello I made a site with validated XHTML and CSS. It works fine also. Only in IE i see the site build up without CSS (very fast though) and then the CSS is used to build the page. When i use...
7
by: per9000 | last post by:
Dear Black Knight, I have no quarrel with you sir Knight, but I must import your parents. SHORT VERSION: I tried three variants of "from ../brave.py import sir_robin", one works. I want...
49
by: Martin Unsal | last post by:
I'm using Python for what is becoming a sizeable project and I'm already running into problems organizing code and importing packages. I feel like the Python package system, in particular the...
8
by: jmDesktop | last post by:
Hi, I have this code (learning from Core Python, Chun's book), module named chap2.py. class FooClass(object): version=0.1 def __init__(self, nm='John Doe'): self.name=nm print 'Created a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.