Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError on OS X install #14

Open
j2l opened this issue Nov 6, 2011 · 21 comments
Open

ImportError on OS X install #14

j2l opened this issue Nov 6, 2011 · 21 comments

Comments

@j2l
Copy link

j2l commented Nov 6, 2011

Hi,

After pipe2py install (feedparser and simplejson are already installed), testing or compiling throws:
python testbasics.py
Traceback (most recent call last):
File "testbasics.py", line 9, in
from pipe2py import Context
ImportError: No module named pipe2py

on Mac OS X 10.5

Any ideas?

@ggaughan
Copy link
Owner

ggaughan commented Nov 6, 2011

Do you have your PYTHONPATH environment variable set to the pipe2py directory? In Linux this would be something like:

export PYTHONPATH=/home/mypath/pipe2py

But perhaps setenv for Max OS X?

@j2l
Copy link
Author

j2l commented Nov 6, 2011

Thanks,
I checked on http://docs.python.org/using/mac.html
path seems to be ok with:
export PYTHONPATH=$PYTHONPATH:/Applications/XAMPP/htdocs/pipeline/pipe2py

but no luck so far,
I also tried on a pure linux box (my shared web server) and I have the same problem so I guess I missed something on both installs.

@ggaughan
Copy link
Owner

ggaughan commented Nov 6, 2011

Ah - yes. the pipe2py directory with the __init__.py is the package directory, so you'll want:

export PYTHONPATH=$PYTHONPATH:/Applications/XAMPP/htdocs/pipeline

@j2l
Copy link
Author

j2l commented Nov 7, 2011

Yeah, I did that too, no luck, it's stuck ...
Any other idea?

On Sun, Nov 6, 2011 at 9:35 PM, Greg Gaughan <
[email protected]>wrote:

Ah - yes. the pipe2py directory with the init.py is the package
directory, so you'll want:

export PYTHONPATH=$PYTHONPATH:/Applications/XAMPP/htdocs/pipeline


Reply to this email directly or view it on GitHub:
#14 (comment)

@ggaughan
Copy link
Owner

ggaughan commented Nov 7, 2011

What do you get when you

$ python
>>> import sys
>>> print sys.path

@j2l
Copy link
Author

j2l commented Nov 7, 2011

I get:
['', '/Library/Python/2.5/site-packages/feedparser-5.0.1-py2.5.egg',
'/Library/Python/2.5/site-packages/simplejson-2.2.1-py2.5-macosx-10.5-i386.egg',
'/Applications/XAMPP/xamppfiles/htdocs/pipeline/test/pipeline',
'/Applications/XAMPP/htdocs/pipeline/pipe2py',
'/Applications/XAMPP/htdocs/pipeline',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python25.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/lib-dynload',
'/Library/Python/2.5/site-packages',
'/System/Library/Frameworks/Python.framework/Versions/2.5/Extras/lib/python/PyObjC']

On Mon, Nov 7, 2011 at 6:08 PM, Greg Gaughan <
[email protected]>wrote:

What do you get when you

$ python

import sys
print sys.path


Reply to this email directly or view it on GitHub:
#14 (comment)

@ggaughan
Copy link
Owner

ggaughan commented Nov 7, 2011

Hmm. Well presumably one of those paths should have the package files in it. Though I wonder what the difference is between the contents of /Applications/XAMPP/xamppfiles/htdocs/pipeline/test/pipeline and /Applications/XAMPP/htdocs/pipeline.

I don't use a Mac, so I'm not sure if you need any extra steps.
Perhaps Python doesn't have permission to read the package directory or files?

What happens if you try to access the package __init__.py file from within Python:

$python
>>> open('/Applications/XAMPP/htdocs/pipeline/pipe2py/__init__.py').readlines()[:5]

@j2l
Copy link
Author

j2l commented Nov 7, 2011

open('/Applications/XAMPP/htdocs/pipeline/pipe2py/init.py').readlines()[:5]
Traceback (most recent call last):
File "", line 1, in
IOError: [Errno 2] No such file or directory:
'/Applications/XAMPP/htdocs/pipeline/pipe2py/init.py'
open('/Applications/XAMPP/htdocs/pipeline/init.py').readlines()[:5]
['#pipe2py package\n', '#Author: Greg Gaughan\n', '\n', '#See LICENCE file
for licence details\n', '\n']

On Mon, Nov 7, 2011 at 8:54 PM, Greg Gaughan <
[email protected]>wrote:

Hmm. Well presumably one of those paths should have the package files in
it. Though I wonder what the difference is between the contents of
/Applications/XAMPP/xamppfiles/htdocs/pipeline/test/pipeline and
/Applications/XAMPP/htdocs/pipeline.

I don't use a Mac, so I'm not sure if you need any extra steps.
Perhaps Python doesn't have permission to read the package directory or
files?

What happens if you try to access the package __init__.py file from
within Python:

$python

open('/Applications/XAMPP/htdocs/pipeline/pipe2py/init.py').readlines()[:5]


Reply to this email directly or view it on GitHub:
#14 (comment)

@ggaughan
Copy link
Owner

ggaughan commented Nov 7, 2011

So the files seem to be there but they need to be in a package directory named pipe2py for the import pipe2py to work. So it looks like the files in /Applications/XAMPP/htdocs/pipeline/ need to be moved into the /Applications/XAMPP/htdocs/pipeline/pipe2py/ sub-directory. Having /Applications/XAMPP/htdocs/pipeline in sys.path should then be enough to locate the pipe2py package.

@j2l
Copy link
Author

j2l commented Nov 8, 2011

Right! It works now.
Thanks for your help

I think I misunderstood this phrase in README:

Setting up the environment

If using a Python version before 2.6 then simplejson is needed:

At first I put simplejson source code in pipeline/pipe2py and pipe2py in
pipeline/

FIXED!

On Mon, Nov 7, 2011 at 11:06 PM, Greg Gaughan <
[email protected]>wrote:

So the files seem to be there but they need to be in a package directory
named pipe2py for the import pipe2py to work. So it looks like the
files in /Applications/XAMPP/htdocs/pipeline/ need to be moved into the
/Applications/XAMPP/htdocs/pipeline/pipe2py/ sub-directory. Having
/Applications/XAMPP/htdocs/pipeline in sys.path should then be enough
to locate the pipe2py package.


Reply to this email directly or view it on GitHub:
#14 (comment)

@j2l
Copy link
Author

j2l commented Nov 8, 2011

Ok, I can compile but I cannot execute it.

My compiled pipe throws:
$ python pipe_0373e6dbc0f888a2f5af7d342e56eaba.py

Traceback (most recent call last):
File "pipe_0373e6dbc0f888a2f5af7d342e56eaba.py", line 38, in
for i in p:
File "/Applications/XAMPP/htdocs/pipeline/pipe2py/modules/pipeoutput.py",
line 18, in pipe_output
for item in _INPUT:
File "/Applications/XAMPP/htdocs/pipeline/pipe2py/modules/pipeloop.py",
line 35, in pipe_loop
for item in _INPUT:
File "/Applications/XAMPP/htdocs/pipeline/pipe2py/modules/piperegex.py",
line 30, in pipe_regex
matchc = re.compile(match, re.DOTALL) #compile for speed and we need
to pass flags
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 180, in compile
return _compile(pattern, flags)
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py",
line 229, in _compile
raise TypeError, "first argument must be string or compiled pattern"
TypeError: first argument must be string or compiled pattern

It's not the real pipe cause I want to keep it private for now.

There's no argument in this pipe, everything is hardcoded within it,
why does it ask for first argument?
what (and how) should I put as argument?

Thanks for your help, again ;-)

On Tue, Nov 8, 2011 at 7:56 AM, j2l [email protected] wrote:

Right! It works now.
Thanks for your help

I think I misunderstood this phrase in README:

Setting up the environment

If using a Python version before 2.6 then simplejson is needed:

At first I put simplejson source code in pipeline/pipe2py and pipe2py in
pipeline/

FIXED!

On Mon, Nov 7, 2011 at 11:06 PM, Greg Gaughan <
[email protected]>wrote:

So the files seem to be there but they need to be in a package directory
named pipe2py for the import pipe2py to work. So it looks like the
files in /Applications/XAMPP/htdocs/pipeline/ need to be moved into the
/Applications/XAMPP/htdocs/pipeline/pipe2py/ sub-directory. Having
/Applications/XAMPP/htdocs/pipeline in sys.path should then be enough
to locate the pipe2py package.


Reply to this email directly or view it on GitHub:
#14 (comment)

@ggaughan
Copy link
Owner

ggaughan commented Nov 9, 2011

I'll make a note to improve the README text - I can see how it could be confusing.

Sounds like there could something strange with the pipe definition. I can't seem to access it via pipes or pipe2py for some reason - could you send me the definition please? Either a link that works, or using -j when compiling to get a .json representation.

Thanks,
Greg

@ggaughan
Copy link
Owner

ggaughan commented Nov 9, 2011

Sorry - just saw the bit about it being private. It sounds like a regex module parameter is missing - perhaps the loop failed to pass it something to work with. I'll need the .json file to investigate further though.

@j2l
Copy link
Author

j2l commented Nov 11, 2011

When trying to compile with Json:
python compile.py pipe_0373e6dbc0f888a2f5af7d342e56eaba.py
Traceback (most recent call last):
File "compile.py", line 356, in
pipe_def = json.loads(pjson)
File
"/Library/Python/2.5/site-packages/simplejson-2.2.1-py2.5-macosx-10.5-i386.egg/simplejson/init.py",
line 413, in loads
return _default_decoder.decode(s)
File
"/Library/Python/2.5/site-packages/simplejson-2.2.1-py2.5-macosx-10.5-i386.egg/simplejson/decoder.py",
line 402, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File
"/Library/Python/2.5/site-packages/simplejson-2.2.1-py2.5-macosx-10.5-i386.egg/simplejson/decoder.py",
line 420, in raw_decode
raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line 1
column 0 (char 0)

Not sure if it's related but this pipe is heavy on computing, it takes
20-40s to execute in yahoo pipes and sometimes fails. Regex is used with no
errors but result can be cleaner so I get some warnings at execution.
Result is a list with locations so I can get the map result too.

On Wed, Nov 9, 2011 at 1:37 PM, Greg Gaughan <
[email protected]>wrote:

Sorry - just saw the bit about it being private. It sounds like a regex
module parameter is missing - perhaps the loop failed to pass it something
to work with. I'll need the .json file to investigate further though.


Reply to this email directly or view it on GitHub:
#14 (comment)

@j2l
Copy link
Author

j2l commented Nov 11, 2011

Sorry for my simple question:
What option -j? What's the full command line to get for instance
pipe_2de0e4517ed76082dcddf66f7b218057.json?

I tracked another problem with a fetch page loop in the same pipe ( I
truncated the original pipe to track the bugs):
$ python pipe_XX.py
Traceback (most recent call last):
File "pipe_XX.py", line 33, in
for i in p:
File "/Applications/XAMPP/htdocs/pipeline/pipe2py/modules/pipeoutput.py",
line 18, in pipe_output
for item in _INPUT:
File "/Applications/XAMPP/htdocs/pipeline/pipe2py/modules/pipeloop.py",
line 50, in pipe_loop
for i in p:
File
"/Applications/XAMPP/htdocs/pipeline/pipe2py/modules/pipefetchpage.py",
line 40, in pipe_fetchpage
request = urllib2.Request(url)
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib2.py",
line 190, in init
self.__original = unwrap(url)
File
"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/urllib.py",
line 1009, in unwrap
url = url.strip()
AttributeError: 'NoneType' object has no attribute 'strip'

I don't get what it means.

In Yahoo pipes, result of this fetch page loop section is in the form:
0
content
html
link http://...
loop:fetchpage
content
html
1...

Thanks again,

On Fri, Nov 11, 2011 at 2:59 PM, j2l [email protected] wrote:

When trying to compile with Json:
python compile.py pipe_0373e6dbc0f888a2f5af7d342e56eaba.py
Traceback (most recent call last):
File "compile.py", line 356, in
pipe_def = json.loads(pjson)
File
"/Library/Python/2.5/site-packages/simplejson-2.2.1-py2.5-macosx-10.5-i386.egg/simplejson/init.py",
line 413, in loads
return _default_decoder.decode(s)
File
"/Library/Python/2.5/site-packages/simplejson-2.2.1-py2.5-macosx-10.5-i386.egg/simplejson/decoder.py",
line 402, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File
"/Library/Python/2.5/site-packages/simplejson-2.2.1-py2.5-macosx-10.5-i386.egg/simplejson/decoder.py",
line 420, in raw_decode
raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line
1 column 0 (char 0)

Not sure if it's related but this pipe is heavy on computing, it takes
20-40s to execute in yahoo pipes and sometimes fails. Regex is used with no
errors but result can be cleaner so I get some warnings at execution.
Result is a list with locations so I can get the map result too.

On Wed, Nov 9, 2011 at 1:37 PM, Greg Gaughan <
[email protected]>wrote:

Sorry - just saw the bit about it being private. It sounds like a regex
module parameter is missing - perhaps the loop failed to pass it something
to work with. I'll need the .json file to investigate further though.


Reply to this email directly or view it on GitHub:
#14 (comment)

@ggaughan
Copy link
Owner

Use the -s option to create a .json file created (sorry, not -j), e.g.

python compile.py -s -p 2de0e4517ed76082dcddf66f7b218057

(Your earlier python compile.py pipe_0373e6dbc0f888a2f5af7d342e56eaba.py will fail: compile.py expects a json file, not the pipe module itself.)

@j2l
Copy link
Author

j2l commented Nov 11, 2011

ok, thanks. I can produce .json file.
I don't know how to help debug this. I cannot give access to this pipe or
json file.

On Fri, Nov 11, 2011 at 5:27 PM, Greg Gaughan <
[email protected]>wrote:

Use the -s option to create a .json file created (sorry, not -j), e.g.

python compile.py -s -p 2de0e4517ed76082dcddf66f7b218057

(Your earlier python compile.py pipe_0373e6dbc0f888a2f5af7d342e56eaba.py
will fail: compile.py expects a json file, not the pipe module itself.)


Reply to this email directly or view it on GitHub:
#14 (comment)

@ggaughan
Copy link
Owner

Could you find out the value of rule just before line 30 in piperegex.py (the point where it fails).

My guess is that the regular expression is missing for some reason. What is the loop module looping over?

@j2l
Copy link
Author

j2l commented Nov 26, 2011

how to do that?
I tried:
print "%s" %(match) in piperegex.py
but no luck

@ggaughan
Copy link
Owner

print rule

would be better. Or trace into the exception and and inspect the value of rule.

I'm not sure how far we'll get with this indirect debugging ;)

@reubano
Copy link
Contributor

reubano commented Nov 9, 2014

I just made a bunch of updates, can you check and see if the issue is still there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants