LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-17-2016, 10:29 AM   #1
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Rep: Reputation: 52
learning and installing Python 3


I need to write "trow-away" scripts (or scripts to be used only once) but for UTF-8 files and it seems that Python 3 is much better than Python 2.7 (which comes with my Debian 7 distro) for that purpose so I have followed a "how to" from a Ubuntu forum explaining how to download and install Python-3.3.5 with the following instructions for which I have absolutely no experience:

Code:
wget http://www.python.org/ftp/python/3-3.5/Python-3-3.5.tar.xz
tar xJf ./Python-3-3.5.tar.xz
cd ./Python-3-3.5
./configure --prefix=/opt/python3-3
make && sudo make install
Python-3.3.5 was installed successfully in
Code:
/home/user_x/Python-3.3.5
and
/opt/python3.3/bin
with no problem but after changing the first line of a Python 2.7 script to
Code:
#!/home/user_x/Python-3.3.5
or
#!/opt/python3.3/bin
I get the message:
Code:
bash: ./test.py: /home/user_x/Python-3.3.5: bad interpreter: Permission denied
or
bash: ./test.py: /opt/python3.3/bin: bad interpreter: Permission denied
This is even after "chown" everything owned by root in /home/user_x/Python-3.3.5 and /opt/python3.3/bin to "user_x" and giving directory ~/Python-3.3.5/ permissions 777
Both text.py and the directory Python-3.3.5 (and its files) belong to the same user_x and group user_x. There is 2 larges files as below and subdirectory "Python" contains all the .c .h .o files.
Code:
-rw-r--r--  1 user_x user_x 17304682 May 17 21:43 libpython3.3m.a
-rwxr-xr-x  1 user_x user_x 10180893 May 17 21:43 python
drwxr-xr-x  2 user_x user_x     4096 May 17 21:43 Python
This is contents of /opt/python3.3/bin:
Code:
lrwxrwxrwx 1 root root               8 May 17 21:45 2to3 -> 2to3-3.3
-rwxr-xr-x 1 user_x user_x      105 May 17 21:45 2to3-3.3
lrwxrwxrwx 1 root root               7 May 17 21:45 idle3 -> idle3.3
-rwxr-xr-x 1 user_x user_x      103 May 17 21:45 idle3.3
lrwxrwxrwx 1 root root               8 May 17 21:45 pydoc3 -> pydoc3.3
-rwxr-xr-x 1 user_x user_x        88 May 17 21:45 pydoc3.3
lrwxrwxrwx 1 root root               9 May 17 21:45 python3 -> python3.3
-rwxr-xr-x 2 user_x user_x 10180893 May 17 21:44 python3.3
lrwxrwxrwx 1 root root            17 May 17 21:45 python3.3-config -> python3.3m-config
-rwxr-xr-x 2 user_x user_x 10180893 May 17 21:44 python3.3m
-rwxr-xr-x 1 user_x user_x     1982 May 17 21:45 python3.3m-config
lrwxrwxrwx 1 root root       16 May 17 21:45 python3-config -> python3.3-config
lrwxrwxrwx 1 root root       10 May 17 21:45 pyvenv -> pyvenv-3.3
-rwxr-xr-x 1 user_x user_x      240 May 17 21:45 pyvenv-3.3
Could anyone tell me what could be wrong?

Thank you for your help.
 
Old 05-17-2016, 11:05 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
I have no idea what kind of guide you followed, but it is TERRIBLE!

The way to install Python 3 on Debian is:
Code:
sudo apt-get install python3
Or if you haven't configured sudo, as root:
Code:
apt-get install python3
Do this, and then issue this command:
Code:
which python3
If all is well you should see:
Code:
which python3
/usr/bin/python3
The version in the repos for Debian 7 is Python 3.2 by the way.

Once you get Python 3 installed correctly, you can use this at the beginning of your files:
Code:
#!/usr/bin/env python3
Best regards,
HMW

Edit: I forgot to say, "good luck and happy hacking!" Python 3 is my go-to lagnuage these days when a bash script simply isn't enough. Go for it and have fun!

Last edited by HMW; 05-17-2016 at 11:28 AM.
 
1 members found this post helpful.
Old 05-17-2016, 11:18 AM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,774

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by rblampain View Post
Python-3.3.5 was installed successfully in
Code:
/home/user_x/Python-3.3.5
and
/opt/python3.3/bin
with no problem but after changing the first line of a Python 2.7 script to
Code:
#!/home/user_x/Python-3.3.5
or
#!/opt/python3.3/bin
You need a filename after the "#!", not a directory name, e.g.
Code:
#!/opt/python3.3/bin/python3
 
1 members found this post helpful.
Old 05-18-2016, 01:29 AM   #4
rblampain
Senior Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 11
Posts: 1,288

Original Poster
Rep: Reputation: 52
Thank you for the answers.
Quote:
You need a filename after the "#!", not a directory name, e.g.
was the solution.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I got error while installing python-tk python-psycopg2 python-twisted saili kadam Linux - Newbie 1 09-05-2015 03:03 AM
Learning Python...how? InvRa Programming 11 02-22-2011 01:15 AM
learning python skripy Linux - Software 2 03-27-2009 10:13 PM
Learning Python... where do i start?? Claus Programming 2 09-02-2003 06:42 AM
Try Python, O'reilly Learning Python haknot Programming 5 02-15-2002 08:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration