Re: ImportError: cannot import name _remove_dead_weakref

2018-05-03 Thread dieter
Chris Angelico  writes:
> ...
> Somewhere, you have a mismatch of versions. Make sure you're using the
> same Python version for everything. You have some Python 2.7 messing
> up your 3.5.

I have had similar problems. In my case, an active "PYTHONPATH" envvar
was responsible -- "unset"ting this envar has resolved the problem for me.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Weird side effect of default parameter

2018-05-03 Thread Gary Herron
This is a well known feature of Python.   It's a very common "gotcha" to 
new Python programmers.


Google "Mutable default parameters in Python" for long list of 
explanations and fixes.


In short, don't use a mutable object as a default parameter.


Gary Herron



On 05/03/2018 12:47 PM, python-list@python.org wrote:

Hello,

I don't understand the behavior of the code below. Why does the dict property
"a" of both objects contain the same keys? This is only if "a=dict" is in
the initializer. If I put self.a = dict() into the init function, I get two
separate dicts



class Foo(object):
 def __init__(self, x, a=dict()):
 self.x = x
 self.a = a
 self.a[x] = x


c = Foo(1)
d = Foo(2)

print(c.__dict__)
print(d.__dict__)


robert


--
Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology
(425) 895-4418

--
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: cannot import name _remove_dead_weakref

2018-05-03 Thread Chris Angelico
On Fri, May 4, 2018 at 6:10 AM, joseph pareti  wrote:
> please excuse my full python ignorance, however if I set PYTHONPTAH as shown
> below, then the results are quite different than before:
>
> $ echo $PYTHONPATH
> /backupdata/anaconda/lib/python2.7/
> $ python tf_train_pressure.py
> Fatal Python error: Py_Initialize: Unable to get the locale encoding
>   File "/backupdata/anaconda/lib/python2.7/encodings/__init__.py", line 124
> raise CodecRegistryError,\
> ^
> SyntaxError: invalid syntax
>
> Current thread 0x7f2b4459f700 (most recent call first):
> Aborted (core dumped)
>

Somewhere, you have a mismatch of versions. Make sure you're using the
same Python version for everything. You have some Python 2.7 messing
up your 3.5.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: cannot import name _remove_dead_weakref

2018-05-03 Thread joseph pareti
please excuse my full python ignorance, however if I set PYTHONPTAH as
shown below, then the results are quite different than before:

$ echo $PYTHONPATH
/backupdata/anaconda/lib/python2.7/
$ python tf_train_pressure.py
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/backupdata/anaconda/lib/python2.7/encodings/__init__.py", line 124
raise CodecRegistryError,\
^
SyntaxError: invalid syntax

Current thread 0x7f2b4459f700 (most recent call first):
Aborted (core dumped)


2018-05-03 19:15 GMT+02:00 Chris Angelico :

> On Fri, May 4, 2018 at 1:53 AM, joseph pareti 
> wrote:
> > on an Ubuntu VM with :
> >
> >
> >1. Linux JP-Paid-UBUNTU-DSVM 4.13.0-1014-azure
> >2. Python 3.5.4 :: Anaconda custom (64-bit)
> >
> > $ manta manta_genSimData.py
> > Loading script 'manta_genSimData.py'
> > Traceback (most recent call last):
> >
> > skipping some details
> >
> > ...
> > File "/anaconda/lib/python2.7/weakref.py", line 14, in 
> > from _weakref import (
> > *ImportError: cannot import name _remove_dead_weakref*
> > Script finished.
>
> Somehow, the details you're skipping include jumping from a Python
> 3.5.4 into a Python 2.7's standard library. Check your Anaconda
> settings and see if you have something bizarre going on with your
> PYTHONPATH.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Weird side effect of default parameter

2018-05-03 Thread Robert Latest via Python-list
Hello,

I don't understand the behavior of the code below. Why does the dict property
"a" of both objects contain the same keys? This is only if "a=dict" is in
the initializer. If I put self.a = dict() into the init function, I get two
separate dicts



class Foo(object):
def __init__(self, x, a=dict()):
self.x = x
self.a = a
self.a[x] = x


c = Foo(1)
d = Foo(2)

print(c.__dict__)
print(d.__dict__)


robert
-- 
https://mail.python.org/mailman/listinfo/python-list


Problems with pip (Windows 10)

2018-05-03 Thread TheSeeker
Dear All,

Within the past week I have run into a problem with pip on my work machine 
(Windows 10, x64, Python 3.6) where pip errors like so:

C:\>c:\Python36\Scripts\pip install --trusted-host pypi.org --trusted-host 
pypi.python.org --trusted-host files.pythonhosted.org --no-color 
--default-timeout=100 pint
Collecting pint
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, 
status=None)) after connection broken by 'ProtocolError('Connection aborted.', 
ConnectionResetError(10054, 'An existing connection was forcibly closed by the 
remote host', None, 10054, None))': 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
Could not install packages due to an EnvironmentError: 
HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries 
exceeded with url: 
/packages/1e/40/6938f7d544eef208a8183c2c80624289e8a4f4e0aea43f4658b9527077de/Pint-0.8.1.tar.gz
 (Caused by ProtocolError('Connection aborted.', ConnectionResetError(10054, 
'An existing connection was forcibly closed by the remote host', None, 10054, 
None)))

C:\>c:\Python36\Scripts\pip --version
pip 10.0.1 from c:\python36\lib\site-packages\pip-10.0.1-py3.6.egg\pip (python 
3.6)

The only thing I have changed is I upgraded to Windows 10 version 1803. 
pip had been working before that point, but my place of work might have changed 
things as well from a network perspective.

Has anyone else seen something like this?

Sincerely,
Duane
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: syntax error (?) on ubuntu

2018-05-03 Thread Ned Batchelder

On 5/3/18 9:11 AM, Joel Goldstick wrote:

On Thu, May 3, 2018 at 9:06 AM, joseph pareti  wrote:

$ python tf_simple.py

/anaconda/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36:
FutureWarning: Conversion of the second argument of issubdtype from `float`
to `np.floating` is deprecated. In future, it will be treated as
`np.float64 == np.dtype(float).type`.
   from ._conv import register_converters as _register_converters
Traceback (most recent call last):
   File "tf_simple.py", line 29, in 
 import uniio
   File "../tools/uniio.py", line 132
 if(PY3K): ID = ID.decode("utf-8")
  ^
TabError: inconsistent use of tabs and spaces in indentation
--
https://mail.python.org/mailman/listinfo/python-list

Check to see if you have a tab after the colon in the last line.  You
must use colons or spaces, but not both



/tabs/ or spaces.

--Ned.
--
https://mail.python.org/mailman/listinfo/python-list


Re: ImportError: cannot import name _remove_dead_weakref

2018-05-03 Thread Chris Angelico
On Fri, May 4, 2018 at 1:53 AM, joseph pareti  wrote:
> on an Ubuntu VM with :
>
>
>1. Linux JP-Paid-UBUNTU-DSVM 4.13.0-1014-azure
>2. Python 3.5.4 :: Anaconda custom (64-bit)
>
> $ manta manta_genSimData.py
> Loading script 'manta_genSimData.py'
> Traceback (most recent call last):
>
> skipping some details
>
> ...
> File "/anaconda/lib/python2.7/weakref.py", line 14, in 
> from _weakref import (
> *ImportError: cannot import name _remove_dead_weakref*
> Script finished.

Somehow, the details you're skipping include jumping from a Python
3.5.4 into a Python 2.7's standard library. Check your Anaconda
settings and see if you have something bizarre going on with your
PYTHONPATH.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


ImportError: cannot import name _remove_dead_weakref

2018-05-03 Thread joseph pareti
on an Ubuntu VM with :


   1. Linux JP-Paid-UBUNTU-DSVM 4.13.0-1014-azure
   2. Python 3.5.4 :: Anaconda custom (64-bit)

$ manta manta_genSimData.py
Loading script 'manta_genSimData.py'
Traceback (most recent call last):

skipping some details

...
File "/anaconda/lib/python2.7/weakref.py", line 14, in 
from _weakref import (
*ImportError: cannot import name _remove_dead_weakref*
Script finished.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: syntax error (?) on ubuntu

2018-05-03 Thread Joel Goldstick
On Thu, May 3, 2018 at 9:06 AM, joseph pareti  wrote:
> $ python tf_simple.py
>
> /anaconda/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36:
> FutureWarning: Conversion of the second argument of issubdtype from `float`
> to `np.floating` is deprecated. In future, it will be treated as
> `np.float64 == np.dtype(float).type`.
>   from ._conv import register_converters as _register_converters
> Traceback (most recent call last):
>   File "tf_simple.py", line 29, in 
> import uniio
>   File "../tools/uniio.py", line 132
> if(PY3K): ID = ID.decode("utf-8")
>  ^
> TabError: inconsistent use of tabs and spaces in indentation
> --
> https://mail.python.org/mailman/listinfo/python-list

Check to see if you have a tab after the colon in the last line.  You
must use colons or spaces, but not both

-- 
Joel Goldstick
http://joelgoldstick.com/blog
http://cc-baseballstats.info/stats/birthdays
-- 
https://mail.python.org/mailman/listinfo/python-list


syntax error (?) on ubuntu

2018-05-03 Thread joseph pareti
$ python tf_simple.py

/anaconda/envs/py35/lib/python3.5/site-packages/h5py/__init__.py:36:
FutureWarning: Conversion of the second argument of issubdtype from `float`
to `np.floating` is deprecated. In future, it will be treated as
`np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Traceback (most recent call last):
  File "tf_simple.py", line 29, in 
import uniio
  File "../tools/uniio.py", line 132
if(PY3K): ID = ID.decode("utf-8")
 ^
TabError: inconsistent use of tabs and spaces in indentation
-- 
https://mail.python.org/mailman/listinfo/python-list