Regarding os.path related error with pyjs

108 views
Skip to first unread message

Swapnil Bhavekar

unread,
Mar 11, 2013, 8:19:54 AM3/11/13
to pyjs-...@googlegroups.com
Hi guys,

I am new to pyjs, i am working on File Search application with Pyjs. With pyjama installation on windows, i got some examples but there is no examples in which os.path get used .

in my program,

when i used FRoot_Path = os.path.expanduser('~') I am getting some Tried_01 TypeError: $p.NotImplemented is not a function kind of error.

on python2.7.3 shell it gives me proper output

>>>import os
>>>import sys
>>> os.path.expanduser('~')
'C:\\Documents and Settings\\dev1'

so can you give me some advice regarding this. if you can send some os.path related examples reference link with pyjs then also it is ok.

Łukasz Mach

unread,
Mar 11, 2013, 8:42:30 AM3/11/13
to pyjs-...@googlegroups.com
I think you won't have os.path in your pyjs environment. Think about it
- it's python in javascript. Javascript usually has no access to your
files, paths, etc...

--
pozdrawiam

Łukasz Mach - lukas...@pagema.net

Swapnil Bhavekar

unread,
Mar 14, 2013, 12:41:10 AM3/14/13
to pyjs-...@googlegroups.com
ok thanks for reply, so now i am importing basic python code as module in pys file, in that way it gives me "Tried_02 ImportError: No module named WCP, WCP in context None"

in this Tried_02 is my pyjs folder and WCP is my python file from another folder, which i tried to import in this ( Tried_02 ) example.

Łukasz Mach

unread,
Mar 14, 2013, 6:02:32 AM3/14/13
to pyjs-...@googlegroups.com

On 14.03.2013 05:41, Swapnil Bhavekar wrote:
> ok thanks for reply, so now i am importing basic python code as module
> in pys file, in that way it gives me "Tried_02 ImportError: No module
> named WCP, WCP in context None"
>
> in this Tried_02 is my pyjs folder and WCP is my python file from
> another folder, which i tried to import in this ( Tried_02 ) example.

How do you build it? What's exact command of pyjsbuild?

Do you set PYJSPATH? If not - how should pyjsbuild know that your module
should be in different folder?

Swapnil Bhavekar

unread,
Mar 14, 2013, 6:35:27 AM3/14/13
to pyjs-...@googlegroups.com
Hi Lukasz, 


1) C:\Pyjama\examples\Tried_02>c:\Pyjama\bin\pyjsbuild.bat Tried_02.py

this is the way ( command ) i build files, it gives me 

Building : Tried_02
PYJSPATH : [
    C:\Pyjama\examples\Tried_02
    C:\Pyjama\library
    C:\Pyjama\addons
]
Built to : C:\Pyjama\examples\Tried_02\output

but at the end when i open html files in browser it gives me this error : Tried_02 ImportError: No module named Tried_03.WCP, Tried_03.WCP in context None 

2) No, i have not set PYJSPATH path variable, instead of it i have added python & pyjama's path in Path variable in environment variables.

I have tried to add WCP module by using :

import os
import sys
#from Tried_03 import WCP
sys.path.append('C:\Tried_03')
import WCP

normal way because package import of python gives me some another error's ( thats why i have comment it )
 I think by adding it in sys path it should get that file easiliy, but actually i don't why such kind of errors are coming.


for Pyjamas installation on windows i have understand the steps given in these link's :

Thanks & Regards,
Swapnil





--

--- You received this message because you are subscribed to a topic in the Google Groups "Pyjs.org Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyjs-users/-rCTjFlAqik/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to pyjs-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Łukasz Mach

unread,
Mar 14, 2013, 6:50:41 AM3/14/13
to pyjs-...@googlegroups.com
On 14.03.2013 11:35, Swapnil Bhavekar wrote:
> Hi Lukasz,
>
> *
> *
> *1) C:\Pyjama\examples\Tried_02>c:\Pyjama\bin\pyjsbuild.bat Tried_02.py*
> *
> *
> this is the way ( command ) i build files, it gives me
> *
> *
> *Building : Tried_02*
> *PYJSPATH : [*
> * C:\Pyjama\examples\Tried_02*
> * C:\Pyjama\library*
> * C:\Pyjama\addons*
> *]*
> *Built to : C:\Pyjama\examples\Tried_02\output*
>
> but at the end when i open html files in browser it gives me this error
> : *Tried_02 ImportError: No module named Tried_03.WCP, Tried_03.WCP in
> context None *
> *
> *
> 2) No, i have not set PYJSPATH path variable, instead of it i have added
> python & pyjama's path in Path variable in environment variables.
>
> I have tried to add WCP module by using :
>
> import os
> import sys
> #from Tried_03 import WCP
> sys.path.append('C:\Tried_03')
> import WCP
>
> normal way because package import of python gives me some another

It's not normal way IMHO :).

You need to have your WCP module in your import path. For CPython it's
PYTHONPATH env variable. For pyjsbuild it's PYJSPATH.

So, if I were you, I would add c:\Tried_03 to your PYJSPATH and import
WCP in your code.

Swapnil Bhavekar

unread,
Mar 14, 2013, 7:05:25 AM3/14/13
to pyjs-...@googlegroups.com
thanks buddy for quick reply, 

as you've said i have added all variable properly in system variable now. 

1) PYTHONPATH = C:\Python27

2) PYJSPATH   = C:\Pyjama\bin;c:\Tried_03 

as again build the file but that error is not get removed still


Łukasz Mach

unread,
Mar 14, 2013, 7:06:59 AM3/14/13
to pyjs-...@googlegroups.com
On 14.03.2013 12:05, Swapnil Bhavekar wrote:
> thanks buddy for quick reply,
>
> as you've said i have added all variable properly in system variable now.
>
> 1) PYTHONPATH = C:\Python27
>
> 2) PYJSPATH = C:\Pyjama\bin;c:\Tried_03
>
> as again build the file but that error is not get removed still

Please remove dir C:\Pyjama\examples\Tried_02\output and paste full
outpu of building.

Swapnil Bhavekar

unread,
Mar 14, 2013, 7:14:58 AM3/14/13
to pyjs-...@googlegroups.com
sorry last lines i am not able to under stand, i should try to build Tried_02 from another directory or install pyjama newly ?


Swapnil Bhavekar

unread,
Mar 14, 2013, 7:23:51 AM3/14/13
to pyjs-...@googlegroups.com
i have tried to build from another directory with simple helloworld type example,  
with importing same module here : 

D:\SwapHello>c:\Pyjama\bin\pyjsbuild.bat SwapHello.py
Building : SwapHello
PYJSPATH : [
    D:\SwapHello
    C:\Pyjama\library
    C:\Pyjama\addons
]
Translating file : D:\SwapHello\SwapHello.py
Built to : D:\SwapHello\output


that helloworld with window.alert and rootpanel().add() all function working properly but when i add that import code of WCP ,
it gives me same pevious error in browser : SwapHello ImportError: No module named WCP, WCP in context None

Łukasz Mach

unread,
Mar 14, 2013, 7:24:04 AM3/14/13
to pyjs-...@googlegroups.com
On 14.03.2013 12:14, Swapnil Bhavekar wrote:
> sorry last lines i am not able to under stand, i should try to build
> Tried_02 from another directory or install pyjama newly ?

1. rmdir (or whatever command is in windows)
c:\pyjama\examples\tried_02\output
2. do your build command with your changed PYJSPATH
3. copy output of command (that letters which appears on the screen),
4. paste it in email, add more letters around letters you pasted, like
"Hi" and "Regards" :)
5. click send.

[...]
>
> Please remove dir C:\Pyjama\examples\Tried_02\__output and paste
> full outpu of building.
--
pozdrawiam

�ukasz Mach - lukas...@pagema.net

Łukasz Mach

unread,
Mar 14, 2013, 7:25:13 AM3/14/13
to pyjs-...@googlegroups.com
On 14.03.2013 12:23, Swapnil Bhavekar wrote:
> i have tried to build from another directory with simple helloworld type
> example,
> with importing same module here :
>
> *D:\SwapHello>c:\Pyjama\bin\pyjsbuild.bat SwapHello.py*
> *Building : SwapHello*
> *PYJSPATH : [*
> * D:\SwapHello*
> * C:\Pyjama\library*
> * C:\Pyjama\addons*
> *]*
> *Translating file : D:\SwapHello\SwapHello.py*
> *Built to : D:\SwapHello\output*
>
>
> that helloworld with window.alert and rootpanel().add() all function
> working properly but when i add that import code of WCP ,
> it gives me same pevious error in browser : *SwapHello ImportError: No
> module named WCP, WCP in context None*
>

Sorry man, but I cannot help you more than saying that you're still have
no WCP in your PYJSPATH. Just add it to PYJSPATH and you will be happy.

EOT.

Swapnil Bhavekar

unread,
Mar 16, 2013, 3:14:37 AM3/16/13
to pyjs-...@googlegroups.com
Thanks Łukasz, its working. 

Now i am able to import WCP module in pyjs example. 

and extremely sorry for my stupidity.

Thanks and Regards,
Swapnil


Reply all
Reply to author
Forward
0 new messages