[Tutor] Doubts about installing python3.1 in squeeze

2014-05-22 Thread Markos

Hi,

I'm learning Python and I'm using Debian 6.0 (squeeze)

The installed version is 2.6.6. (python -V)

I have seen some recommendations for beginners to invest in version 3.

I found package of Python 3.1 in repository for squeeze.

I am considering installing Python 3.1 with

apt-get install python3.1

But I found the site 
http://www.circuidipity.com/python2-and-python3.html information on how 
to keep the two versions using virtualenv.


Also I found in the /usr/bin python2.5 and python2.6

And in /usr/lib python2.4, python2.5 and python2.6

Can I just run apt-get install python3.1 or should I do any other 
configuration?


I'm confused.


Are there any risk to install python3.1 and some programs stop working 
on my debian squeeze?


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


Re: [Tutor] Doubts about installing python3.1 in squeeze

2014-05-23 Thread Markos

On 22-05-2014 13:22, Alex Kleider wrote:

On 2014-05-22 06:17, Markos wrote:

Hi,

I'm learning Python and I'm using Debian 6.0 (squeeze)

The installed version is 2.6.6. (python -V)

I have seen some recommendations for beginners to invest in version 3.

I found package of Python 3.1 in repository for squeeze.

I am considering installing Python 3.1 with

apt-get install python3.1

But I found the site
http://www.circuidipity.com/python2-and-python3.html information on
how to keep the two versions using virtualenv.

Also I found in the /usr/bin python2.5 and python2.6

And in /usr/lib python2.4, python2.5 and python2.6

Can I just run apt-get install python3.1 or should I do any other 
configuration?


I'm confused.


Are there any risk to install python3.1 and some programs stop working
on my debian squeeze?

Thanks for any tips?
Markos


On Ubuntu both v2 and v3 are installed by default.
Have you tried typing
python3
on the command line?
If you get the interpreter, it's installed.
Then you just have to use a different shebang line in your code files:
#!/usr/bin/env python3

I don't have a debian system close at hand to test this myself.

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


Dear,

Thanks everyone for the tips.

I tried to install python3.1 with the command

apt-get install python3.1

and use the shebang #!/usr/bin/env python3 in the source code header.

It works.

But to use Tkinter I also had to install the package python3-tk

apt-get intall python3-tk

Now I have in /usr/bin

python python3 python2.5 python2.6 python3.1

python is a link to python2.6 and python3 is a link to python3.1

Until now everything is working.

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


[Tutor] Idle - ImportError: No module named numpy

2015-03-06 Thread Markos

Hi,

I'm beginning to study the numpy.

When I open a terminal (Debian Squeeze) and run the python interpreter 
the command "import numpy as np" run without errors.


But when I run the same command on idle3 the following error appears.

>>> import numpy as np
Traceback (most recent call last):
  File "", line 1, in 
import numpy as np
ImportError: No module named numpy

How configure idle to load the numpy module?

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


Re: [Tutor] Idle - ImportError: No module named numpy

2015-03-09 Thread Markos

On 06-03-2015 21:43, boB Stepp wrote:

On Fri, Mar 6, 2015 at 12:27 PM, Markos  wrote:
   

Hi,

I'm beginning to study the numpy.

When I open a terminal (Debian Squeeze) and run the python interpreter the
command "import numpy as np" run without errors.

But when I run the same command on idle3 the following error appears.

 

import numpy as np
   

Traceback (most recent call last):
   File "", line 1, in
 import numpy as np
ImportError: No module named numpy

How configure idle to load the numpy module?
 

You don't by chance have Python 2 installed as well as Python 3, where
Python 2 is associated with your terminal session? And your numpy
module is for Python 2, not 3? That is my first thought, but I'm sure
the experts will chime in shortly with a more definitive diagnosis.


   

Hi boB,

I installed numpy in Debian (6.0) with the command:
apt-get install python-numpy

I just find that this package is exclusively for python 2.5 and 2.6

The idle3 use Python 3.1.3.

How to install numpy for Python 3 in order to use it with the idle?

Is there any simple way?

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


Re: [Tutor] Idle - ImportError: No module named numpy

2015-03-11 Thread Markos

On 10-03-2015 16:48, Oscar Benjamin wrote:

On 10 March 2015 at 13:59, Markos  wrote:
   

I don't have the python3-pip in the repository, then I downloaded the
get-pip.py from:

https://bootstrap.pypa.io/get-pip.py

But when running the command "python3 get-pip.py" appears the error message
(end of message).
 

Looks like a bug in pip or in the get-pip script. What version of
python3 are you using?

You'll just need to install setuptools and pip the old-fashioned way.

First check if you already have setuptools:

 $ python3
 Python 3.4.0 (default, Apr 11 2014, 13:05:11)
 [GCC 4.8.2] on linux
 Type "help", "copyright", "credits" or "license" for more information.
 >>>  import setuptools
 >>>  setuptools.__version__
 '3.3'

If not you can install it from here (download the .tar.gz file near
the bottom of the page):

 https://pypi.python.org/pypi/setuptools

Extract the .tar.gz file, cd into it and run

 $ sudo python3 setup.py install

Then do the same for pip from here:

 https://pypi.python.org/pypi/pip

Then you should be able to install things with

 $ python3 -m pip install

where package_name would be e.g. numpy and you'll need to be root or use sudo.

   

I found a message about a bug with pip at
https://github.com/pypa/pip/issues/1093

Is it the same kind of error?
 

I don't think so.

   

Any tip?
 

See above.

   

And another doubt.

Is there any risk of numpy module to be used by python3 to conflict with the
numpy module that is already installed for python2.5 and python2.6?
 

No. As long as you install setuptools and pip with "python3 setup.py
install" and install numpy with "python3 -m pip install numpy" then
your Python 2.x installations will be unaffected.


Oscar

   

Hi Oscar,

I downloaded the file 
https://pypi.python.org/packages/source/s/setuptools/setuptools-14.0.tar.gz


tar -xzvf setuptools-14.0.tar.gz
cd setuptools-14.0
python3 setup.py install

Then I downloaded the file 
https://pypi.python.org/packages/source/p/pip/pip-6.0.8.tar.gz

tar -xzvf pip-6.0.8.tar.gz
cd pip-6.0.8
python3 setup.py install

And the command python3 -m pip list

pip (6.0.8)
setuptools (14.0)

But the command to install numpy gave an error message:

# python3 -m pip install numpy

Collecting numpy
  Exception:
  Traceback (most recent call last):
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/basecommand.py", 
line 232, in main

  status = self.run(options, args)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/commands/install.py", 
line 339, in run

  requirement_set.prepare_files(finder)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/req/req_set.py", 
line 333, in prepare_files

  upgrade=self.upgrade,
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/index.py", 
line 305, in find_requirement

  page = self._get_page(main_index_url, req)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/index.py", 
line 783, in _get_page

  return HTMLPage.get_page(link, req, session=self.session)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/index.py", 
line 872, in get_page

  "Cache-Control": "max-age=600",
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/_vendor/requests/sessions.py", 
line 473, in get

  return self.request('GET', url, **kwargs)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/download.py", 
line 365, in request

  return super(PipSession, self).request(method, url, *args, **kwargs)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/_vendor/requests/sessions.py", 
line 461, in request

  resp = self.send(prep, **send_kwargs)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/_vendor/requests/sessions.py", 
line 573, in send

  r = adapter.send(request, **kwargs)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/_vendor/cachecontrol/adapter.py", 
line 43, in send

  resp = super(CacheControlAdapter, self).send(request, **kw)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/_vendor/requests/adapters.py", 
line 370, in send

  timeout=timeout
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", 
line 518, in urlopen

  body=body, headers=headers)
File 
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/_vendor/requests/packages/urllib3/connectionpool.py", 
line 322, in _make_request

  self._validate_conn(conn

Re: [Tutor] Idle - ImportError: No module named numpy

2015-03-12 Thread Markos

On 09-03-2015 21:25, Oscar Benjamin wrote:

On 9 March 2015 at 18:09, Markos  wrote:
   

I installed numpy in Debian (6.0) with the command:
apt-get install python-numpy

I just find that this package is exclusively for python 2.5 and 2.6

The idle3 use Python 3.1.3.

How to install numpy for Python 3 in order to use it with the idle?

Is there any simple way?
 

Hi Markos,

I'm not sure about Squeeze but on this Ubuntu 14.04 system you can
install numpy for Python 3 by typing:

 $ sudo apt-get install python3-numpy

The Python 3 version of the package is a relatively new addition to
the repositories though so it may not be available in Squeeze.

If there is no package then you can build numpy yourself. It's not too
hard to do. First make sure that you have pip installed for python3.
You can check if it's installed by typing:

 $ python3 -m pip

If it says

 /usr/bin/python3: No module named pip

then you don't have pip. You may be able to install pip with

 $ sudo apt-get install python3-pip

If not then you can install it by downloading the get-pip.py script from here:

 https://pip.pypa.io/en/latest/installing.html

Once you have that you can run it as

 $ sudo python3 get-pip.py

Once pip is installed you can use it to install lots of things
including numpy. For numpy in particular though you'll need to first
install the compilers and Python 3 header files:

 $ sudo apt-get install build-essential python3-dev

Now you can use pip to install numpy for python3:

 $ sudo python3 -m pip install numpy

This will download numpy from PyPI and then try to compile and install
it. Compiling numpy takes a while and you will see a lot of strange
compiler messages. If it fails then just post the very last part of
the output here. It will probably mean that you need to install more
compilers or something.

If it succeeds then you should be able to import numpy e.g.:

 $ python3
 Python 3.4.0 (default, Apr 11 2014, 13:05:11)
 [GCC 4.8.2] on linux
 Type "help", "copyright", "credits" or "license" for more information.
 >>>  import numpy
 >>>  numpy.cos(1)
 0.54030230586813977


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

   


Hi.

I don't have the python3-pip in the repository, then I downloaded the 
get-pip.py from:


https://bootstrap.pypa.io/get-pip.py

But when running the command "python3 get-pip.py" appears the error 
message (end of message).


I found a message about a bug with pip at 
https://github.com/pypa/pip/issues/1093


Is it the same kind of error?

Any tip?

And another doubt.

Is there any risk of numpy module to be used by python3 to conflict with 
the numpy module that is already installed for python2.5 and python2.6?


I still don't know the structure of Python packages.

Thank you very much for your detailed explanation.

Markos


# python3 get-pip.py
Collecting pip
  Exception:
  Traceback (most recent call last):
File "/tmp/tmpn0At3p/pip.zip/pip/basecommand.py", line 232, in main
  status = self.run(options, args)
File "/tmp/tmpn0At3p/pip.zip/pip/commands/install.py", line 339, in run
  requirement_set.prepare_files(finder)
File "/tmp/tmpn0At3p/pip.zip/pip/req/req_set.py", line 333, in 
prepare_files

  upgrade=self.upgrade,
File "/tmp/tmpn0At3p/pip.zip/pip/index.py", line 305, in 
find_requirement

  page = self._get_page(main_index_url, req)
File "/tmp/tmpn0At3p/pip.zip/pip/index.py", line 783, in _get_page
  return HTMLPage.get_page(link, req, session=self.session)
File "/tmp/tmpn0At3p/pip.zip/pip/index.py", line 872, in get_page
  "Cache-Control": "max-age=600",
File "/tmp/tmpn0At3p/pip.zip/pip/_vendor/requests/sessions.py", 
line 473, in get

  return self.request('GET', url, **kwargs)
File "/tmp/tmpn0At3p/pip.zip/pip/download.py", line 365, in request
  return super(PipSession, self).request(method, url, *args, **kwargs)
File "/tmp/tmpn0At3p/pip.zip/pip/_vendor/requests/sessions.py", 
line 461, in request

  resp = self.send(prep, **send_kwargs)
File "/tmp/tmpn0At3p/pip.zip/pip/_vendor/requests/sessions.py", 
line 573, in send

  r = adapter.send(request, **kwargs)
File "/tmp/tmpn0At3p/pip.zip/pip/_vendor/cachecontrol/adapter.py", 
line 43, in send

  resp = super(CacheControlAdapter, self).send(request, **kw)
File "/tmp/tmpn0At3p/pip.zip/pip/_vendor/requests/adapters.py", 
line 370, in send

  timeout=timeout
File 
"/tmp/tmpn0At3p/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", 
line 518, in urlo

Re: [Tutor] Idle - ImportError: No module named numpy

2015-03-14 Thread Markos

On 13-03-2015 12:34, Oscar Benjamin wrote:

On 11 March 2015 at 19:43, Markos  wrote:
   

On 10-03-2015 16:48, Oscar Benjamin wrote:
 

Looks like a bug in pip or in the get-pip script. What version of
python3 are you using?
   

But the command to install numpy gave an error message:

# python3 -m pip install numpy

Collecting numpy
   Exception:
   Traceback (most recent call last):
 File
"/usr/local/lib/python3.1/dist-packages/pip-6.0.8-py3.1.egg/pip/basecommand.py",
 

Ah okay. You're using Python 3.1. Python 3.1 is not supported by pip,
setuptools or numpy. That may explain the error messages that you get
with pip. Also it explains why there is no python3-numpy package in
your repositories. Essentially most major Python packages are aimed at
Python 2.6/2.7 and Python 3.2 upwards but not Python 3.0 or 3.1. Does
squeeze have a newer version of Python 3 (e.g. 3.2)?

It may be possible to get numpy to work with python 3.1 but I would
recommend either:
1) Stick to Python 2.
2) Upgrade to wheezy - I haven't checked but I assume that it has a
newer version of Python 3.
3) Install Python 3.4 manually (by compiling it yourself).

If you do want to try and install numpy for python 3.1 then you would
download the .tar.gz from here:
https://pypi.python.org/pypi/numpy
Then extract it, cd in, and run "python3 setup.py install".

The people who make numpy don't support Python 3.1 though which means
that they don't try to guarantee that it will work so you may
encounter more problems.


Oscar

   

Hi Oscar,

Despite failing to install numpy for Python 3.1, this exchange of 
messages helped me to understand the "Python world": ^)


Thank you very much for your attention.
Markos
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] difference between array([1,0,1]) and array([[1,0,1]])

2019-06-21 Thread Markos

Hi,

I'm studying Numpy and I don't understand the difference between


vector_1 = np.array( [ 1,0,1 ] )


with 1 bracket and


vector_2 = np.array( [ [ 1,0,1 ] ] )


with 2 brackets

The shape of vector_1 is:


vector_1.shape

(3,)

But the shape of vector_2 is:


vector_2.shape

(1, 3)

The transpose on vector_1 don't work:


vector_1.T

array([1, 0, 1])

But the transpose method in vector_2 works fine:


vector_2.T

array([[1],
   [0],
   [1]])


I thought that both vectors would be treated as an matrix of 1 row and 3 
columns.


Why this difference?

Any tip?

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


Re: [Tutor] Difference between array( [1, 0, 1] ) and array( [ [1, 0, 1] ] )

2019-06-22 Thread Markos

Thanks Edmondo, Stephen, Mats and Steven you for the tips,

I studied linear algebra many years ago and I remember only a few rudiments.

But I was trying to visualize (in a geometric way) how the numpy 
represents arrays, and what the geometrical meaning of the transpose 
operation made by numpy.


I think I understood a little bit more.

The number of nested brackets indicates the number of array dimensions.
the vector ( [1,2] ) is one-dimensional, but the vector ( [ [1,2] ] ) is 
two-dimensional.


v_1 = np.array( [1,2] )
> v_1.shape
(2,)
> v_1
v_1
> v_1
array( [1, 2] )
> v_2 = np.array( [ [1,2] ] )
> v_2.shape
(1, 2)

And it does not make sense to transpose a one-dimensional array.

> v_1.T
array( [1, 2] )
> v_2.T
array( [ [1],
 [2] ] )

Anothe example:

vector_1 = np.array( [   1,   2,   3,   4,   5,   6,   7,   8  ] )

  ^

vector_2 = np.array( [    [1, 2, 3, 4],    [5, 6, 7, 8]  ]  )

  ^  ^

vector_3 = np.array( [   [   [1,2],  [3,4]  ], [  [5,6],   [7,8] ]  ]  )

  ^ ^ ^

> vector_1
array([1, 2, 3, 4, 5, 6, 7, 8])
> vector_2
array( [ [1, 2, 3, 4],
 [5, 6, 7, 8] ] )
> vector_3
array( [ [ [1, 2],
   [3, 4] ],

 [ [5, 6],
   [7, 8] ] ] )

And looking for some tutorial about geometric aspects of matrices and 
the geometric meaning of the transpose I found that transposed is 
"mirrored along the diagonal" at:


https://www.coranac.com/documents/geomatrix/

>vector_1.T
array([1, 2, 3, 4, 5, 6, 7, 8])
> vector_2.T
array( [ [1, 5],
 [2, 6],
 [3, 7],
 [4, 8] ] )
> vector_3.T
array( [ [ [1, 5],
   [3, 7]],

 [ [2, 6],
   [4, 8] ] ] )

Thank you,
Markos

Em 21-06-2019 07:44, edmondo.giovanno...@gmail.com escreveu:

Every array in numpy has a number of dimensions,
"np.array" is a function that can create an array numpy given a list.

when  you write
vector_1  = np.array([1,2,1])
you are passing a list of number to thet function array that will create a 1D 
array.
As you are showing:
vector_1.shape
will return a tuple with the sizes of each dimension of the array that is:
(3,)
Note the comma thta indicate that is a tuple.
While if you write:
vector_2 = np.array([[1,2,3]])
You are passing a list of list to the function array that will instruct it to 
crete a 2D array, even though the size of the first dimension is 1:
vector_2.shape
(1,3)
It is still a tuple as you can see.
Try:
vector_3 = np.array([[1,2,3],[4,5,6]])
And you'll see that i'll return a 2D array with a shape:
vector_3.shape
(2,3)
As the external list has 2 elements that is two sublists each with 3 elements.
The vector_2 case is just when the external list has only 1 element.

I hope it is more clear now.
Cherrs,

   

   
   


Il giorno venerdì 21 giugno 2019 08:29:36 UTC+2, Markos ha scritto:

Hi,

I'm studying Numpy and I don't understand the difference between


vector_1 = np.array( [ 1,0,1 ] )

with 1 bracket and


vector_2 = np.array( [ [ 1,0,1 ] ] )

with 2 brackets

The shape of vector_1 is:


vector_1.shape

(3,)

But the shape of vector_2 is:


vector_2.shape

(1, 3)

The transpose on vector_1 don't work:


vector_1.T

array([1, 0, 1])

But the transpose method in vector_2 works fine:


vector_2.T

array([[1],
     [0],
     [1]])


I thought that both vectors would be treated as an matrix of 1 row and 3
columns.

Why this difference?

Any tip?

Thank you,
Markos


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