Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
Hi Amrita: I tried to figure out, for kicks, how to do what I THINK is what
you're trying to do... I've never even opened a .txt file in Python before,
so you can take all this with a big grain of salt... Anyway, if you take
your example of your original database:

1 GLY HA2=3.7850 HA3=3.9130
2 SER H=8.8500 HA=4.3370 N=115.7570
3 LYS H=8.7530 HA=4.0340 HB2=1.8080 N=123.2380
 4 LYS H=7.9100 HA=3.8620 HB2=1.7440 HG2=1.4410 N=117.9810
5 LYS H=7.4450 HA=4.0770 HB2=1.7650 HG2=1.4130 N=115.4790
6 LEU H=7.6870 HA=4.2100 HB2=1.3860 HB3=1.6050 HG=1.5130 HD11=0.7690
HD12=0.7690 HD13=0.7690 N=117.3260
7 PHE H=7.8190 HA=4.5540 HB2=3.1360 N=117.0800
8 PRO HD2=3.7450
9 GLN H=8.2350 HA=4.0120 HB2=2.1370 N=116.3660
10 ILE H=7.9790 HA=3.6970 HB=1.8800 HG21=0.8470 HG22=0.8470 HG23=0.8470
HG12=1.6010 HG13=2.1670 N=119.0300
11 ASN H=7.9470 HA=4.3690 HB3=2.5140 N=117.8620
12 PHE H=8.1910 HA=4.1920 HB2=3.1560 N=121.2640
13 LEU H=8.1330 HA=3.8170 HB3=1.7880 HG=1.5810 HD11=0.8620 HD12=0.8620
HD13=0.8620 N=119.1360

I put it in a file ashift.txt. Then:

f = open('ashift.txt', 'r')
lines = f.readlines()

Now I could iterate through lines (it is a list of strings, one per line),
but I just shortcut to play with a single line:

tshift = lines[0]
tshift = tshift.replace("=", ":")
tshift = tshift.splitlines()  # remove the final \n
tshift = tshift.split(" ")

At which point we have something like this:

['1', 'GLY', 'HA2:3.7850', 'HA3:3.9130']

I am out of time, plus I'm very conscious of doing this INCREDIBLY ineptly.
I have spent a bit of time trying to sort out the right way, there might be
some approach involving dialects associated with the csv module, but I
couldn't sort that out. If one could massage the above line (or the
original file) into

[1, 'GLY', {'HA2' : 3.7850, 'HA3' : 3.9130}]

This is what I'd talked about before, and would make reaching your final
output pretty easy, following the stuff I said above.

I KNOW there's a much, much easier way to do this, probably a one-liner (at
least for the file parsing).

You talked about printing this stuff out, but if you are going to process
it further (analyzing it in some way, for example) there might be
implications as to how you proceed with this.

Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
oops, I see Steven pointed out a much cleaner approach. Oh well. Shock &
surprise ;)

Keith


On Mon, Jan 6, 2014 at 3:27 AM, Keith Winston  wrote:

> Hi Amrita: I tried to figure out, for kicks, how to do what I THINK is
> what you're trying to do... I've never even opened a .txt file in Python
> before, so you can take all this with a big grain of salt... Anyway, if you
> take your example of your original database:
>
> 1 GLY HA2=3.7850 HA3=3.9130
> 2 SER H=8.8500 HA=4.3370 N=115.7570
> 3 LYS H=8.7530 HA=4.0340 HB2=1.8080 N=123.2380
>  4 LYS H=7.9100 HA=3.8620 HB2=1.7440 HG2=1.4410 N=117.9810
> 5 LYS H=7.4450 HA=4.0770 HB2=1.7650 HG2=1.4130 N=115.4790
> 6 LEU H=7.6870 HA=4.2100 HB2=1.3860 HB3=1.6050 HG=1.5130 HD11=0.7690
> HD12=0.7690 HD13=0.7690 N=117.3260
> 7 PHE H=7.8190 HA=4.5540 HB2=3.1360 N=117.0800
> 8 PRO HD2=3.7450
> 9 GLN H=8.2350 HA=4.0120 HB2=2.1370 N=116.3660
> 10 ILE H=7.9790 HA=3.6970 HB=1.8800 HG21=0.8470 HG22=0.8470 HG23=0.8470
> HG12=1.6010 HG13=2.1670 N=119.0300
> 11 ASN H=7.9470 HA=4.3690 HB3=2.5140 N=117.8620
> 12 PHE H=8.1910 HA=4.1920 HB2=3.1560 N=121.2640
> 13 LEU H=8.1330 HA=3.8170 HB3=1.7880 HG=1.5810 HD11=0.8620 HD12=0.8620
> HD13=0.8620 N=119.1360
>
> I put it in a file ashift.txt. Then:
>
> f = open('ashift.txt', 'r')
> lines = f.readlines()
>
> Now I could iterate through lines (it is a list of strings, one per line),
> but I just shortcut to play with a single line:
>
> tshift = lines[0]
> tshift = tshift.replace("=", ":")
> tshift = tshift.splitlines()  # remove the final \n
> tshift = tshift.split(" ")
>
> At which point we have something like this:
>
> ['1', 'GLY', 'HA2:3.7850', 'HA3:3.9130']
>
> I am out of time, plus I'm very conscious of doing this INCREDIBLY
> ineptly. I have spent a bit of time trying to sort out the right way, there
> might be some approach involving dialects associated with the csv module,
> but I couldn't sort that out. If one could massage the above line (or the
> original file) into
>
> [1, 'GLY', {'HA2' : 3.7850, 'HA3' : 3.9130}]
>
> This is what I'd talked about before, and would make reaching your final
> output pretty easy, following the stuff I said above.
>
> I KNOW there's a much, much easier way to do this, probably a one-liner
> (at least for the file parsing).
>
> You talked about printing this stuff out, but if you are going to process
> it further (analyzing it in some way, for example) there might be
> implications as to how you proceed with this.
>
> Keith
>
>


-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Amrita Kumari
Hi Steven,

I tried this code:

import csv
with open('file.csv') as f:
 reader = csv.reader(f)
 for row in reader:
 print(row)
 row[0] = int(row[0])

up to this extent it is ok; it is ok it is giving the output as:

['1' , ' GLY' ,  'HA2=3.7850' ,  'HA3=3.9130' , ' ' , ' ' , ' ' , ' ']
[ '2' ,  'SER' ,  'H=8.8500' ,  'HA=4.3370' ,  'N=115.7570' , ' ' , ' ' , '
']
--
---
but the command :

key, value = row[2].split('=', 1)
value = float(value.strip())
print(value)

is giving the value of row[2] element as

['1' , ' GLY' ,  'HA2=3.7850' ,  'HA3=3.9130' , ' ' , ' ' , ' ' , ' ']
3.7850
[ '2' ,  'SER' ,  'H=8.8500' ,  'HA=4.3370' ,  'N=115.7570' , ' ' , ' ' , '
']
8.8500

--
so this is not what I want I want to print all the chemical shift value of
similar atom from each row at one time

like this:

1 HA2=3.7850
2 HA2=nil
3 HA2=nil
.

..
13 HA2=nil

similarly, for atom HA3:

1 HA3=3.9130
2 HA3=nil
3 HA3=nil
...


13 HA3=nil  and so on.

so how to split each item into a key and a numeric value and then search
for similar atom and print its chemical shift value at one time along with
residue no..

Thanks,
Amrita





On Mon, Jan 6, 2014 at 6:44 AM, Steven D'Aprano  wrote:

> Hi Amrita,
>
> On Sun, Jan 05, 2014 at 10:01:16AM +0800, Amrita Kumari wrote:
>
> > I have saved my data in csv format now it is looking like this:
>
> If you have a file in CSV format, you should use the csv module to read
> the file.
>
> http://docs.python.org/3/library/csv.html
>
> If you're still using Python 2.x, you can read this instead:
>
> http://docs.python.org/2/library/csv.html
>
>
> I think that something like this should work for you:
>
> import csv
> with open('/path/to/your/file.csv') as f:
> reader = csv.reader(f)
> for row in reader:
> print(row)
>
> Of course, you can process the rows, not just print them. Each row will
> be a list of strings. For example, you show the first row as this:
>
> > 2,ALA,C=178.255,CA=53.263,CB=18.411,,
>
> so the above code should print this for the first row:
>
> ['2', 'ALA', 'C=178.255', 'CA=53.263', 'CB=18.411', '', '', '',
> '', '', '', '', '', '']
>
>
> You can process each field as needed. For example, to convert the
> first field from a string to an int:
>
> row[0] = int(row[0])
>
> To split the third item 'C=178.255' into a key ('C') and a numeric
> value:
>
> key, value = row[2].split('=', 1)
> value = float(value.strip())
>
>
>
> Now you know how to read CSV files. What do you want to do with the data
> in the file?
>
>
>
> --
> Steven
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Activating virtualenv in Windows

2014-01-06 Thread Rafael Knuth
Hej guys,

does anyone know how to activate virtualenv in Windows?
In Terminal it's:

source bin/activate

Couldn't find the corresponding command for Windows that actually worked.
Any ideas?

Thanks!

Rafael
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Activating virtualenv in Windows

2014-01-06 Thread Srinivas Nyayapati
Hello

> On Jan 6, 2014, at 6:08 AM, Rafael Knuth  wrote:
>
> Hej guys,
>
> does anyone know how to activate virtualenv in Windows?
> In Terminal it's:
>
> source bin/activate


Just run the script directly from the prompt -

C://bin/activate

HTH
-Srini
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Activating virtualenv in Windows

2014-01-06 Thread eryksun
On Mon, Jan 6, 2014 at 5:59 AM, Rafael Knuth  wrote:
>
> does anyone know how to activate virtualenv in Windows?
> In Terminal it's:
>
> source bin/activate
>
> Couldn't find the corresponding command for Windows that actually worked.
> Any ideas?

Scripts are installed to `Scripts` on Windows.

http://www.virtualenv.org/en/latest/virtualenv.html#windows-notes

http://www.virtualenv.org/en/latest/virtualenv.html#activate-script
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] More or less final Chutes & Ladders

2014-01-06 Thread spir

On 01/05/2014 08:40 PM, Keith Winston wrote:

On Sun, Jan 5, 2014 at 2:52 AM, Mark Lawrence wrote:


Homework for you :)  Write a line of code that creates a list of say 3 or
4 integers, then write a line that creates a tuple with the same integers.
  Use the dis module to compare the byte code that the two lines of code
produce.  The difference is interesting.




Well... that was a very interesting assignment, though I'm going to have to
chew on it for a while to understand. I can see that the processing code
for a tuple is considerably shorter... it is processed in a gulp instead of
bite by byte... it doesn't have the "Build List" step at all (what goes on
inside of THAT?)... but I can't claim to really understand what I'm looking
at.

I notice, for example, if I include only constants (immutable types) in my
tuple, then it does that gulp thing. If I include a list in there too, all
hell breaks loose, and suddenly I'm Building Tuples (what goes on inside of
THAT?). A tuple of tuples still goes down in a single swallow, of course.

Sadly, you can see how my mind works here... hey, this was FUN! You can
assign me homework any time, teach!


A version of Mark's assigment, with only simple tuple items, but some consts and 
some vars:


from dis import dis

x,y = 1,2

def f (i,j):   # line 5 in source
a,b = 1,2
t1 = (1,2)
t2 = (a,b)
t3 = (x,y)
t4 = (i,j)
l = [1,2]

print(dis(f))

  6   0 LOAD_CONST   3 ((1, 2))
  3 UNPACK_SEQUENCE  2
  6 STORE_FAST   2 (a)
  9 STORE_FAST   3 (b)

  7  12 LOAD_CONST   4 ((1, 2))
 15 STORE_FAST   4 (t1)

  8  18 LOAD_FAST2 (a)
 21 LOAD_FAST3 (b)
 24 BUILD_TUPLE  2
 27 STORE_FAST   5 (t2)

  9  30 LOAD_GLOBAL  0 (x)
 33 LOAD_GLOBAL  1 (y)
 36 BUILD_TUPLE  2
 39 STORE_FAST   6 (t3)

 10  42 LOAD_FAST0 (i)
 45 LOAD_FAST1 (j)
 48 BUILD_TUPLE  2
 51 STORE_FAST   7 (t4)

 11  54 LOAD_CONST   1 (1)
 57 LOAD_CONST   2 (2)
 60 BUILD_LIST   2
 63 STORE_FAST   8 (l)
 66 LOAD_CONST   0 (None)
 69 RETURN_VALUE

[I call here const a value that is always the same, at every execution; thus in 
principle know not only to the programmer, but to the compiler. I don't mean 
immutable.]


The interesting part for me is the difference of construction when tuple items 
are variable: the build_tuple routine. t2 is also const, abeit so-to-say an 
"implicit" const tuple, while t1 is explicitely const, in value notation itself. 
t2 is variable, since x & y may change in the meantime (between their first def 
and call to f). t3 is variable by so-to-say definition of "variable".


This is a kind of little optimisation in the case a tuple is obviously const. It 
is probably worth it because tuples are fix-size, since they are immutable (they 
may just be fix-size arrays in the backstage, I don't know). Certainly python 
does not even attempt such an optimisation for list due to their mutable and 
flexible-size structure (they are flexible-size, dynamic arrays).


Denis
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Keith Winston
Amrita, it doesn't seem like the code you are providing is the code you are
running. I wonder if you are running it all at the Python command line or
something, and have to type it in every time? You should put it in a file,
and save & run that file,  and then cut and paste it directly into your
emails, so we can see what you're actually running. There are a number of
small things in the code you've posted that wouldn't run, I think...

Keith


On Mon, Jan 6, 2014 at 3:57 AM, Amrita Kumari  wrote:

> Hi Steven,
>
> I tried this code:
>
> import csv
> with open('file.csv') as f:
>  reader = csv.reader(f)
>  for row in reader:
>  print(row)
>  row[0] = int(row[0])
>
> up to this extent it is ok; it is ok it is giving the output as:
>
> ['1' , ' GLY' ,  'HA2=3.7850' ,  'HA3=3.9130' , ' ' , ' ' , ' ' , ' ']
> [ '2' ,  'SER' ,  'H=8.8500' ,  'HA=4.3370' ,  'N=115.7570' , ' ' , ' ' ,
> ' ']
> --
> ---
> but the command :
>
> key, value = row[2].split('=', 1)
> value = float(value.strip())
> print(value)
>
> is giving the value of row[2] element as
>
> ['1' , ' GLY' ,  'HA2=3.7850' ,  'HA3=3.9130' , ' ' , ' ' , ' ' , ' ']
> 3.7850
> [ '2' ,  'SER' ,  'H=8.8500' ,  'HA=4.3370' ,  'N=115.7570' , ' ' , ' ' ,
> ' ']
> 8.8500
> 
> --
> so this is not what I want I want to print all the chemical shift value of
> similar atom from each row at one time
>
> like this:
>
> 1 HA2=3.7850
> 2 HA2=nil
> 3 HA2=nil
> .
> 
> ..
> 13 HA2=nil
>
> similarly, for atom HA3:
>
> 1 HA3=3.9130
> 2 HA3=nil
> 3 HA3=nil
> ...
> 
> 
> 13 HA3=nil  and so on.
>
> so how to split each item into a key and a numeric value and then search
> for similar atom and print its chemical shift value at one time along with
> residue no..
>
> Thanks,
> Amrita
>
>
>
>
>
> On Mon, Jan 6, 2014 at 6:44 AM, Steven D'Aprano wrote:
>
>> Hi Amrita,
>>
>> On Sun, Jan 05, 2014 at 10:01:16AM +0800, Amrita Kumari wrote:
>>
>> > I have saved my data in csv format now it is looking like this:
>>
>> If you have a file in CSV format, you should use the csv module to read
>> the file.
>>
>> http://docs.python.org/3/library/csv.html
>>
>> If you're still using Python 2.x, you can read this instead:
>>
>> http://docs.python.org/2/library/csv.html
>>
>>
>> I think that something like this should work for you:
>>
>> import csv
>> with open('/path/to/your/file.csv') as f:
>> reader = csv.reader(f)
>> for row in reader:
>> print(row)
>>
>> Of course, you can process the rows, not just print them. Each row will
>> be a list of strings. For example, you show the first row as this:
>>
>> > 2,ALA,C=178.255,CA=53.263,CB=18.411,,
>>
>> so the above code should print this for the first row:
>>
>> ['2', 'ALA', 'C=178.255', 'CA=53.263', 'CB=18.411', '', '', '',
>> '', '', '', '', '', '']
>>
>>
>> You can process each field as needed. For example, to convert the
>> first field from a string to an int:
>>
>> row[0] = int(row[0])
>>
>> To split the third item 'C=178.255' into a key ('C') and a numeric
>> value:
>>
>> key, value = row[2].split('=', 1)
>> value = float(value.strip())
>>
>>
>>
>> Now you know how to read CSV files. What do you want to do with the data
>> in the file?
>>
>>
>>
>> --
>> Steven
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
>>
>
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Keith
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] ubuntu hassles.

2014-01-06 Thread Matthew Ngaha
Hi i wrote about a week ago about the problems i had with importing
sqlite3 on python 3.3 on ubuntu 12.04. Due to this ive tried to revert
back to python 3.2 which is the default installation along wit 2.7.
I've run into 2 problems.

1) I'm new to ubuntu and someone helped me install python3.3 from
source. I've tried 'make uninstall' from the dir containing the source
package but it seems there is no way to get this version off my
computer.

2) I really need to use virtualenv for python3.2. The problem is
python3.3 seems to be the default and overrides every virtualenv thing
i try doing. whether it is pyvenv or virtualenv, the 3.3 version takes
priority. It is located in /usr/local/bin  ... I have no idea where my
3.2 virtualenv is located although i know i definately installed it
with :
  sudo apt-get install python-virtualenv

if i can achieve 1) or 2) im sure the rest would be straightforward.
any ideas? I know this isn't really a python issue but it's a last
resort as the ubuntu guys are unsure of how to solve this. If i can't
resolve it, not to worry, i'll just upgrade my ubuntu to a more recent
version.

Thanks
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Fwd: arrangement of datafile

2014-01-06 Thread Alan Gauld

On 06/01/14 08:57, Amrita Kumari wrote:


up to this extent it is ok; it is ok it is giving the output as:

['1' , ' GLY' ,  'HA2=3.7850' ,  'HA3=3.9130' , ' ' , ' ' , ' ' , ' ']
[ '2' ,  'SER' ,  'H=8.8500' ,  'HA=4.3370' ,  'N=115.7570' , ' ' , ' '
, ' ']
--
---
but the command :

key, value = row[2].split('=', 1)
value = float(value.strip())
print(value)

is giving the value of row[2] element as

['1' , ' GLY' ,  'HA2=3.7850' ,  'HA3=3.9130' , ' ' , ' ' , ' ' , ' ']
3.7850


Which is correct...


so this is not what I want I want to print all the chemical shift value
of similar atom from each row at one time

like this:

1 HA2=3.7850


Which is a combination of the values available to you.

row[0], key, '=', value

So you can put that together in a print as

print (row[0], key, '=', value)


similarly, for atom HA3:


I didn't look at the original data in enough fetail to
know if thats a trivial addition or more.

But can you get the above formatting first?


so how to split each item into a key and a numeric value


Steven showed you that, you just needed to stitch the bits together in 
your desired format.




and then search for similar atom and print its chemical shift
value at one time along with residue no..


Let's solve one problem at a time...


HTH
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ubuntu hassles.

2014-01-06 Thread Wolf Halton
consider this:
sudo apt-get search python3
to find out the exact name or how python 3.3 is registered
sudo apt-get uninstall [that-exact-name]
sudo apt-get reinstall python32
sudo apt-get reinstall python-virtualenv




Wolf Halton

--
This Apt Has Super Cow Powers - http://sourcefreedom.com
Security in the Cloud -
http://AtlantaCloudTech.com



On Mon, Jan 6, 2014 at 11:38 AM, Matthew Ngaha  wrote:

> Hi i wrote about a week ago about the problems i had with importing
> sqlite3 on python 3.3 on ubuntu 12.04. Due to this ive tried to revert
> back to python 3.2 which is the default installation along wit 2.7.
> I've run into 2 problems.
>
> 1) I'm new to ubuntu and someone helped me install python3.3 from
> source. I've tried 'make uninstall' from the dir containing the source
> package but it seems there is no way to get this version off my
> computer.
>
> 2) I really need to use virtualenv for python3.2. The problem is
> python3.3 seems to be the default and overrides every virtualenv thing
> i try doing. whether it is pyvenv or virtualenv, the 3.3 version takes
> priority. It is located in /usr/local/bin  ... I have no idea where my
> 3.2 virtualenv is located although i know i definately installed it
> with :
>   sudo apt-get install python-virtualenv
>
> if i can achieve 1) or 2) im sure the rest would be straightforward.
> any ideas? I know this isn't really a python issue but it's a last
> resort as the ubuntu guys are unsure of how to solve this. If i can't
> resolve it, not to worry, i'll just upgrade my ubuntu to a more recent
> version.
>
> Thanks
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ubuntu hassles.

2014-01-06 Thread Kodiak Firesmith
Hello Matthew,
You likely want to investigate the Linux "Alternatives" system which
handles default pointers to a given version of a program.  People usually
encounter this system for the first time while dealing with different
versions of Java JRE needing to be installed at the same time.

I'm a Redhat guy so I can't walk you through it step by step, but I was
able to pull up some Ubuntu documentation on this system here:
http://manpages.ubuntu.com/manpages/lucid/en/man8/update-alternatives.8.html

Hope this helps!

 - Kodiak Firesmith


On Mon, Jan 6, 2014 at 11:38 AM, Matthew Ngaha  wrote:

> Hi i wrote about a week ago about the problems i had with importing
> sqlite3 on python 3.3 on ubuntu 12.04. Due to this ive tried to revert
> back to python 3.2 which is the default installation along wit 2.7.
> I've run into 2 problems.
>
> 1) I'm new to ubuntu and someone helped me install python3.3 from
> source. I've tried 'make uninstall' from the dir containing the source
> package but it seems there is no way to get this version off my
> computer.
>
> 2) I really need to use virtualenv for python3.2. The problem is
> python3.3 seems to be the default and overrides every virtualenv thing
> i try doing. whether it is pyvenv or virtualenv, the 3.3 version takes
> priority. It is located in /usr/local/bin  ... I have no idea where my
> 3.2 virtualenv is located although i know i definately installed it
> with :
>   sudo apt-get install python-virtualenv
>
> if i can achieve 1) or 2) im sure the rest would be straightforward.
> any ideas? I know this isn't really a python issue but it's a last
> resort as the ubuntu guys are unsure of how to solve this. If i can't
> resolve it, not to worry, i'll just upgrade my ubuntu to a more recent
> version.
>
> Thanks
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ubuntu hassles.

2014-01-06 Thread eryksun
On Mon, Jan 6, 2014 at 11:38 AM, Matthew Ngaha  wrote:
>
> 2) I really need to use virtualenv for python3.2. The problem is
> python3.3 seems to be the default and overrides every virtualenv thing
> i try doing. whether it is pyvenv or virtualenv, the 3.3 version takes
> priority. It is located in /usr/local/bin  ... I have no idea where my
> 3.2 virtualenv is located although i know i definately installed it
> with :
>   sudo apt-get install python-virtualenv


virtualenv allows you to specify the target Python:

virtualenv --python=/usr/bin/python3.3 myenv

Refer to `man virtualenv` for more options.

FYI, here are some commands to introspect a Debian package in the shell:

apt-cache search virtualenv# find packages
apt-cache show python-virtualenv   # description
apt-cache policy python-virtualenv # installed version

apt-file show python-virtualenv# list files

Or use synaptic if you prefer a GUI interface.

> 1) I'm new to ubuntu and someone helped me install python3.3 from
> source. I've tried 'make uninstall' from the dir containing the source
> package but it seems there is no way to get this version off my
> computer.

Ubuntu has a Python 3.3 package. Installation should be simple:

$ sudo apt-get update
$ sudo apt-get install python3.3

If you're building from source, or need to uninstall after a previous
`make install`, use checkinstall to build a package.

Start by installing dependencies.

$ sudo -s
# apt-get update
# apt-get build-dep python3
# apt-get install checkinstall

Change to the source directory to configure and build Python.

# ./configure
# make clean
# make
# make test

Installation defaults to /usr/local. Use the configure option
`--prefix` to target a different directory. Obviously you want to
leave the default if your goal is to uninstall a previous installation
that used the defaults. Refer to `./configure --help` for more
options.

Run checkinstall to create and install a Debian package (-D):

# checkinstall -D --default --fstrans=no\
--pkgname=python3.3-local --pkgversion=3.3.3-1\
make install

Omit `--default` if you don't want the default answers to prompts. In
my experience, filesystem translation (fstrans) has to be disabled to
install Python. Change the last part to `make altinstall` if you want
the major and minor version number used for the files in
/usr/local/bin (e.g. pyvenv-3.3). It's a good idea, but obviously not
if your goal is to uninstall a previous "make install".

When it's finished installing, checkinstall should print the path to
the .deb file and also the command you'll need to uninstall the
package, such as:

# dpkg -r python3.3-local
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ubuntu hassles.

2014-01-06 Thread Matthew Ngaha
On Tue, Jan 7, 2014 at 12:40 AM, eryksun  wrote:

>
> virtualenv allows you to specify the target Python:
>
> virtualenv --python=/usr/bin/python3.3 myenv
>
> Refer to `man virtualenv` for more options.
>
> Or use synaptic if you prefer a GUI interface.
>

> Ubuntu has a Python 3.3 package. Installation should be simple:
>
> $ sudo apt-get update
> $ sudo apt-get install python3.3
>
> If you're building from source, or need to uninstall after a previous
> `make install`, use checkinstall to build a package.
>

I'm currently studying/coding on windows but thanks so so much for
this detailed response. I will try again tomorrow, but im now very
confident! thanks again:)
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ubuntu hassles.

2014-01-06 Thread mes...@juno.com
I tried eryksun's suggestion on installing python3.3: 
"Ubuntu has a Python 3.3 package. Installation should be simple:
$ sudo apt-get update
$ sudo apt-get install python3.3"
on my Ubuntu 12.04 system and got the following message:
E: Unable to locate package python3.3
E: Couldn't find any package by regex 'python3.3'
Eugene Rodriguez

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] ubuntu hassles.

2014-01-06 Thread eryksun
On Mon, Jan 6, 2014 at 10:31 PM, mes...@juno.com  wrote:
> I tried eryksun's suggestion on installing python3.3:
> "Ubuntu has a Python 3.3 package. Installation should be simple:
> $ sudo apt-get update
> $ sudo apt-get install python3.3"
> on my Ubuntu 12.04 system and got the following message:
> E: Unable to locate package python3.3
> E: Couldn't find any package by regex 'python3.3'
> Eugene Rodriguez

The 3.3 package was added in Quantal (12.10):

http://packages.ubuntu.com/quantal/python3.3

For 12.04 you can add the deadsnakes PPA:

https://launchpad.net/~fkrull/+archive/deadsnakes

>From source, you can use the `--prefix` configure option to install to
/opt or your home directory, or use checkinstall to create a local
package.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor