Can the Python interpreter welcome message be suppressed? - python

Instead of:
$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
I'd like, for example:
$ python --quiet
>>>

You can try this:
$ python -ic ""
>>>

Python 3 now has a -q flag:
python3 -q
For Python 2, I have a startup file, so this works for me:
python2 -i "$PYTHONSTARTUP"

Related

/usr/bin/python3: bad interpreter; how to make python3 work again?

I had two versions of python installed (python - 2.7.12 and python3 - 3.5.2). After installing python 3.7.7, I wanted to make it the default of the python3 command by making a few commands. But unfortunately, the python3 command no longer works!
fogang#FF:~$ python
Python 2.7.12 (default, Oct 8 2019, 14:14:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
fogang#FF:~$ python3.7
Python 3.7.7 (default, Mar 10 2020, 17:25:08)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
fogang#FF:~$ python3
bash: /usr/lib/command-not-found : /usr/bin/python3 : mauvais interpréteur: Aucun fichier ou dossier de ce type
fogang#FF:~$
Translated: "/usr/bin/python3: bad interpreter: No file or folder of this type"
There is my /usr/bin
fogang#FF:/usr/bin$ ls python*
python python2.7-config python3.5-config python3.7 python3.7m-config python3m-config pythontex3
python2 python2-config python3.5m python3.7-config python3-config python-config
python2.7 python3.5 python3.5m-config python3.7m python3m pythontex
/usr/bin/python3 is missing. Based on the comments, you're using Ubuntu, so the solution is to simply reinstate it:
sudo ln -s python3.5 /usr/bin/python3
Note that changing the system python3 version on Ubuntu will break things, so the better solution is to use an alias, e.g. put alias python3="python3.7" in your bashrc.

How to switch AWS CLI to Python 3.7 on macOS?

On macOS Mojave 10.14.6, have the following versions of python installed:
Python 2.7.16
Python 2.7.16 (default, May 17 2019, 18:32:33)
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Python 3
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Installed AWS CLI using these steps:
curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
unzip awscli-bundle.zip
sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Now, when I test aws from the command line using aws --version
aws-cli/1.16.247 Python/2.7.16 Darwin/18.7.0 botocore/1.12.237
Question(s):
Is this correct?
Is it supposed to be using Python 3.7.4 instead?
If so, how can I switch this over?
By default the installer will use whatever is in your path for python.
If you want to use Python 3, you need to run something like this to run the installer:
sudo /usr/local/bin/python3 awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
Replace /usr/local/bin/python3 with your path for Python 3 if it's different.
All of this said, if you have both Python environments installed, I'm not aware of any reason to prefer one version over the other for the AWS CLI tool.

How do I use python 3.4 with django 1.9 in my virtualenv?

I am trying to use python 3.4 in my django 1.9 app because python 3.5 is to new and doesn't work with packages that I need. I tried this
virtualenv -p /usr/bin/python3.4 venv
from here
but when Itried that i got this error message
The executable /usr/bin/python3.4 (from --python=/usr/bin/python3.4) does not exist
How canI make this work? thanks
I want to eventually push this to heroku server
EDIT
if I type
apples-MBP:myheroku ray$ python3
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 5 2015, 21:12:44)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
if i type python34
apples-MBP:myheroku ray$ python34
-bash: python34: command not found
if I just type python
Python 2.7.10 (default, Oct 23 2015, 19:19:21)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

./bin/cqlsh saying python not found

I have installed cassandra 3.0.0 and trying to connect to connect cqlsh. when i try to hit ./bin/cqlsh from the dir of installed cassandra I am getting
python not found. I am using ubunut14.04LTS
when i type python2 in my terminal it says
python2
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
when i type python3 in my terminal it says
python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
so this mean it is already installed . But yes when i type
python in terminal it says
python
The program 'python' is currently not installed. You can install it by typing:
apt-get install python-minimal
even when i install python-minimal it doesn work.
please suggest..
Create a symbolic link /usr/bin/python pointing to either /usr/bin/python2 or /usr/bin/python3

ImportError from non-standard Python even though module exists

We have a setup based on CentOS 6.4 but with Python 2.7 (due to historical reasons). Note that CentOS 6 brings Python 2.6. Python 2.7 has been compiled from a Fedora 20 SRPM. In addition, to make it possible to freely use Python RPMs from CentOS 6 along with the 2.7 interpreter, we have created a /usr/lib/python2.7/site-packages/setup.pth file with the contents:
/usr/lib64/python2.6/site-packages
/usr/lib/python2.6/site-packages
Things used to work fine till the need to use protobuf-python-2.3.0-9.el6.x86_64 arose. This RPM has been downloaded from the EPEL repo and is available: here.
$ /usr/bin/python2.7
Python 2.7.4 (default, Mar 17 2015, 00:48:39)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.protobuf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named google.protobuf
One thing that could be helpful is that the import error does not come with Python 2.6:
$ /usr/bin/python
Python 2.6.6 (r266:84292, Jan 22 2014, 09:42:36)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.protobuf
This error does not come with other import statements (e.g. import pip.vcs). It is somehow related to protobuf-python. What could be the reason? Any insight will be appreciated.
EDIT: The protobuf-python RPM installs files into /usr/lib/python2.6/site-packages/google/protobuf and the the 2.7 interpreter's sys.path is:
$ /usr/bin/python2.7 -c 'import sys; print sys.path' | sed -e 's/,/\n/g'
[''
'/usr/lib64/python27.zip'
'/usr/lib64/python2.7'
'/usr/lib64/python2.7/plat-linux2'
'/usr/lib64/python2.7/lib-tk'
'/usr/lib64/python2.7/lib-old'
'/usr/lib64/python2.7/lib-dynload'
'/usr/lib64/python2.7/site-packages'
'/usr/lib/python2.7/site-packages'
'/usr/lib64/python2.6/site-packages'
'/usr/lib/python2.6/site-packages']

Categories

Resources