Why python can't get evironment variable after export?
How to fix this?
λ: export AUTOTEST=/home/anton/eltx/scripts/gitlab/
~
λ: python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['AUTOTEST']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/UserDict.py", line 40, in __getitem__
raise KeyError(key)
KeyError: 'AUTOTEST'
>>>
>>> os.environ.get('AUTOTEST', 'none_value')
'none_value'
>>>
I found the mistake. There was an alias for running python
Related
The problem occurred: ImportError: libhdf5.so.101: cannot open shared object file: No such file or directory,when I install pygrib on linux(centOS6) by Anaconda
Python 3.5.2 |Anaconda custom (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygrib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libhdf5.so.101: cannot open shared object file: No such file or directory
>>> exit()
================================================================
[root#localhost ll]# locate libhdf5.so.101
locate: can not stat () `/var/lib/mlocate/mlocate.db': No such file or directory
Please help me,thank you!
To overcome the limitations of pickle, I switched to multiprocessing_on_dill.
This started to generate an error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 107, in spawn_main
exitcode = _main(fd)
File "C:\ProgramData\Anaconda3\lib\multiprocessing\spawn.py", line 117, in _main
self = reduction.pickle.load(from_parent)
ModuleNotFoundError: No module named '__builtin__'
Is there a way to overcome it?
Surprisingly, it still references C:\ProgramData\Anaconda3\lib\multiprocessing\.
While multiprocessing_on_dill has its own folder C:\ProgramData\Anaconda3\Lib\site-packages\multiprocessing_on_dill with the same set of files.
I'd suggest you use multiprocess instead of multiprocessing_on_dill... the former is better supported, and maintained by the dill author (me). It looks like multiprocess_on_dill is looking for __builtin__, which is where the builtin functions lived in python 2... in python 3, they are in builtins
>$ python
Python 2.7.16 (default, Apr 1 2019, 14:50:56)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
>>>
>$ python
Python 3.6.8 (default, Dec 30 2018, 13:04:41)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import __builtin__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named '__builtin__'
>>> import builtins
>>>
So, I think it's either you are running python 3, and using the python 2 version of the code -- or the module doesn't fully support python 3.
After hours of unsuccessfully trying to use objectpath in a Python3-script, I made the following simple experiment:
>>> from objectpath import *
>>> tree=Tree({"a":1})
>>> tree.execute("$.a")
Expected output: 1
Success with python (2)
~$ python
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from objectpath import *
>>> tree=Tree({"a":1})
>>> tree.execute("$.a")
1
>>>
Error with python3:
Is there something wrong with my installation of Python3 ?
objectpath in P3 neither works in scripts nor on console
$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from objectpath import *
>>> tree=Tree({"a":1})
>>> tree.execute("$.a")
Traceback (most recent call last):
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/parser.py", line 398, in tokenize_python
yield type_map[t[0]], t[1]
KeyError: 4
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/interpreter.py", line 605, in execute
tree=self.compile(expr)
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/interpreter.py", line 38, in compile
ret=EXPR_CACHE[expr]=parse(expr,self.D)
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/parser.py", line 464, in parse
r=expression().getTree()
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/parser.py", line 449, in expression
left=t.led(left)
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/parser.py", line 264, in led
advance()
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/parser.py", line 161, in advance
token=nextToken()
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/parser.py", line 413, in tokenize
for ID, value in source:
File "/home/lisa/.local/lib/python3.6/site-
packages/objectpath/core/parser.py", line 405, in tokenize_python
raise SyntaxError("Syntax error")
To run this in Python 3.x you should pip3 install objectpath otherwise it won't work.
See below how I ran your code:
dell#dell-XPS-15-9572:~/Desktop$ pip3 install objectpath
Collecting objectpath
Downloading https://files.pythonhosted.org/packages/21/6a/ed435be72edd1d60b7363cbb38c34aff3004fee02d1c7f9f01435c318cdb/objectpath-0.5-py2.py3-none-any.whl
Installing collected packages: objectpath
Successfully installed objectpath-0.5
dell#dell-XPS-15-9572:~/Desktop$ python3
Python 3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more
information.
>>> from objectpath import *
>>> tree=Tree({"a":1})
>>> tree.execute("$.a")
1
>>>
Pypy doesn't seem to handle string.maketrans() when arguments are unicode, however CPython does:
$ python
Python 2.7.5 (default, Oct 11 2013, 14:51:32)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> string.maketrans(ur"-/[] ", ur"_____")
'\x00\x01\x02\x03\x04\x05\x06...'
$ pypy
Python 2.7.13 (c925e73810367cd960a32592dd7f728f436c125c, Jun 08 2017, 19:14:08)
[PyPy 5.8.0 with GCC 6.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>> import string
>>>> string.maketrans(ur"-/[] ", ur"_____")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../pypy-5.8-linux_x86_64-portable/lib-python/2.7/string.py", line 78, in maketrans
buf[ord(fromstr[i])] = tostr[i]
TypeError: 'unicode' object cannot be interpreted as an index
Didn't find anything relevant on http://pypy.readthedocs.io/en/latest/cpython_differences.html.
Is this a bug of CPython or PyPy?
That's a "bug", i.e. an unexpected difference. Fixed in 7fe0041fccaa (see line 78 of https://bitbucket.org/pypy/pypy/raw/default/lib-python/2.7/string.py).
Python 2.7.5 (default, Sep 15 2016, 22:37:39)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> shlst="_t=[['00','bank','yx'],['04','airport','jc']]"
>>> eval(shlst)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
_t=[['00','bank','yx'],['04','airport','jc']]
^
SyntaxError: invalid syntax