python path

Other talk about Salix
User avatar
ink3
Posts: 80
Joined: 9. Apr 2011, 14:16

Re: python path

Post by ink3 »

$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib/java/bin:/usr/lib/qt/bin:/usr/share/texmf/bin:.:/home/stahoo/skrypty_bash/
$ cat ~/.bashrc
export PS1='\u[\W]\$ '
export PAGER="most"
export PATH=$PATH:/home/stahoo/skrypty_bash/
export PATH=$PATH:/home/stahoo/skrypty_python/


if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

alias ls='ls --color=auto'stahoo[skrypty_bash]
This bold line ^ is correct?
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: python path

Post by mimosa »

That looks right to me, except maybe you don't want those forward slashes at the end. And maybe that's why it's not working now. I notice they appear when you echo your $PATH - but not for any of the other directories in $PATH.
User avatar
ink3
Posts: 80
Joined: 9. Apr 2011, 14:16

Re: python path

Post by ink3 »

unfortunately does not work

I try change path :
export PYTHONPATH=$PYTHONPATH:/home/stahoo/skrypty_python

$ echo $PYTHONPATH
:/home/stahoo/skrypty_python/

but result is the same
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: python path

Post by mimosa »

No, $PATH, not $PYTHONPATH!

Change it in your .bashrc and reboot, I'd suggest. Leave everything just as it is but remove those slashes. I'm just guessing that that's the problem, but it seems worth a try.

EDIT

Also, maybe you should use $HOME rather than an explicit path. Here is my ~/.profile:

Code: Select all

PATH=$PATH:$HOME/bin
... but again maybe that's not what's causing your problem.
User avatar
ink3
Posts: 80
Joined: 9. Apr 2011, 14:16

Re: python path

Post by ink3 »

ok, bashrc:
export PATH=$PATH:/home/stahoo/skrypty_python

reboot
echo $PATH
...........:/home/stahoo/skrypty_python :)

$ python losuj.py
python: can't open file 'losuj.py': [Errno 2] No such file or directory :(

$ losuj.py
bash: /home/stahoo/skrypty_python/losuj.py: Permission denied

hmm?


$ ls -la losuj.py
-rwxr-xr-x 1 stahoo stahoo 74 Feb 2 11:53 losuj.py
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: python path

Post by mimosa »

Code: Select all

$cd ~/skrypty_python
$./losuj.py
$ls -l losuj.py
User avatar
ink3
Posts: 80
Joined: 9. Apr 2011, 14:16

Re: python path

Post by ink3 »

./losuj.py
bash: ./losuj.py: Permission denied

ls -l losuj.py
-rwxr-xr-x 1 stahoo stahoo 74 Feb 2 11:53 losuj.py
User avatar
mimosa
Salix Warrior
Posts: 3311
Joined: 25. May 2010, 17:02
Contact:

Re: python path

Post by mimosa »

I'm afraid I'm stumped - you own the file and it has execute permissions. Maybe something to do with the script itself? What about the shell script - does that work now?
Shador
Posts: 1295
Joined: 11. Jun 2009, 14:04
Location: Bavaria

Re: python path

Post by Shador »

ink3 wrote: $ losuj.py
bash: /home/stahoo/skrypty_python/losuj.py: Permission denied
Could it be your shebang (#!) is wrong? ;) :P
This caused me an unwanted but at least clean shutdown of a machine at work during a power failure today. :D

For python it should be something like this:

Code: Select all

#!/usr/bin/env python
Image
User avatar
ink3
Posts: 80
Joined: 9. Apr 2011, 14:16

Re: python path

Post by ink3 »

I dont't think so.
losuj.py and losuj-1.py are the same scripts but have different first line.
#!/usr/bin/env python
import random
random.seed()
s=random.randint(1,595)
print s
^ losuj-1.py ; losuj.py has
#!/usr/bin/python
Post Reply