When I start a python interactive session from the command line I am greeted by :
Python 3.9.6 (default, Jun 30 2021, 10:22:16)
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
Is there a way of disabling that message so that I go immediately to the >>> prompt?
Yes, there is a way to do so.
Type in the cmd:
python -q
instead of
python
and this should do the trick.
Related
I try to use ssl module with urllib.request , And my script always die.
So i found this:
Python 3.7.3 (default, Dec 26 2020, 06:35:45)
[GCC 6.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'LibreSSL 3.1.1'
>>> ssl.SSLContext()
Killed
That all infomation i got. And I've g00gle about this , nothing I can found in the world.
Can somebody help me with this trouble? I really need someone help me.
I have a Python 2.7 question, if somebody can help.
When we install a Python module using pip, how do we make it available to all users? Please, see the example below (with module faker). The import works when I am root, but doesn’t work when I am ubuntu user.
I have already tried to install using option --system, and also changing umask, as recommended in some articles I have found. Didn’t work so far. Any ideas?
If we run "which python", both users point to the same one.
root#ip-172-30-244-157:/home/ubuntu#
root#ip-172-30-244-157:/home/ubuntu# python
Python 2.7.17 (default, Sep 30 2020, 13:38:04)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import faker
>>>
>>> exit()
root#ip-172-30-244-157:/home/ubuntu#
root#ip-172-30-244-157:/home/ubuntu#
root#ip-172-30-244-157:/home/ubuntu# exit
exit
ubuntu#ip-172-30-244-157:~$
ubuntu#ip-172-30-244-157:~$
ubuntu#ip-172-30-244-157:~$ python
Python 2.7.17 (default, Sep 30 2020, 13:38:04)
[GCC 7.5.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import faker
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named faker
>>>
Ok, I solved the issue.
In my case, the problematic module was "faker". But, when we install the faker, another additional module is installed as well (in this case - text-unidecode).
Then I uninstalled both modules, ran "umask 022" and re-installed the faker.
This solved the issue for all other users.
Thanks all for the help!
I'm running python 3.6 + gunicorn + django 2.0.5 in docker container with some cyrillic project and that's what I see when I try to log cyrillic strings in console with Django.
'ascii' codec can't encode character '\u0410' in position 0: ordinal not in range(128)
Also this what happens in shell
Python 3.6.5 (default, May 3 2018, 10:08:28)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> :�ириллица
The same time, when i'm running python 3.5 outside docker container, everything is ok:
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> Кириллица
Any ideas how to make python 3.6 inside docker work ok with cyrillic strings?
Use # -*- coding: utf-8 -*- in the first line of your python code.
And in your Dockerfile add:
ENV PYTHONIOENCODING=utf-8
How to prevent echo from input ??
Have tried "getpass()" but no luck.
On Windows IDLE, it doesn't work
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import getpass
>>> p = getpass.getpass(prompt="Input: ")
Warning: Password input may be echoed.
Input: abc <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< It still echos..
On the terminal of the Windows, it works
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:03:43) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import getpass
>>> p = getpass.getpass(prompt="Input: ")
Input:
>>>
Is there a easy way to prevent echo from input ?
I'm assuming your first example there is in IDLE.
From getpass.win_getpass():
if sys.stdin is not sys.__stdin__:
return fallback_getpass(prompt, stream)
IDLE replaces sys.stdin with a different object. getpass detects that somebody has wrapped stdin and fails for security reasons.
See: http://bugs.python.org/issue9290
When I type "python" and return in shell, the following lines will come out:
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
How to surpress these lines please?
An easy way is to call Python as python -i -c "". This will also disable any start-up scripts, though. If you have a start-up script, you can also use python -i ~/.pythonrc.py (or however that script is named).