Hot answers tagged

237

From the comment: sudo update-alternatives --config python Will show you an error: update-alternatives: error: no alternatives for python3 You need to update your update-alternatives , then you will be able to set your default python version. sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 1 sudo update-alternatives --...


119

Ubuntu 16.10+ and Python 3.7 dev sudo apt-get install zlib1g-dev note: i only put this here because it was the top search result for the error, but this resolved my issue. update: also the case for ubuntu 14.04LTS and base kernel at 4.1+


54

Shell loops are slow and bash's are the slowest. Shells aren't meant to do heavy work in loops. Shells are meant to launch a few external, optimized processes on batches of data. Anyway, I was curious how shell loops compare so I made a little benchmark: #!/bin/bash export IT=$((10**6)) echo POSIX: for sh in dash bash ksh zsh; do TIMEFORMAT="%RR %UU %...


37

You can achieve this by applying below simple steps - Check python version on terminal - python --version Get root user privileges. On terminal type - sudo su Write down the root user password Execute this command to switch to python 3.6 - update-alternatives --install /usr/bin/python python /usr/bin/python3 1 Check python version - python --version Done.


35

The solution is : # yum install zlib-devel


23

Simple solution is edit .bashrc and put this line: alias python3=python3.7 Whenever you will write python3 it will replace it with python3.7. Or you can use command update-alternatives which is preferred i.e: sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/...


18

I did a bit of testing, and on my system ran the following--none made the order of magnitude speedup that would be needed to be competitive, but you can make it faster: Test 1: 18.233s #!/bin/bash i=0 while [[ $i -le 4000000 ]] do let i++ done test2: 20.45s #!/bin/bash i=0 while [[ $i -le 4000000 ]] do i=$(($i+1)) done test3: 17.64s #!/bin/...


18

This is a known bug in bash; see the man page and search for "BUGS": BUGS It's too big and too slow. ;) For an excellent primer on the conceptual differences between shell scripting and other programming languages, I highly recommend reading: Why is using a shell loop to process text considered bad practice? The most pertinent excerpts: Shells ...


17

This doesn't work because source is a shell command, so systemd's ExecStart= or ExecStartPre= won't understand them directly... (BTW, the same is true for cd and the &&.) You could achieve that by running a shell explicitly and running all your commands together there: ExecStart=/bin/sh -c 'cd /home/debian/ap/ && source venv-ap/bin/activate ...


14

Using these commands can help you: check the version of python: ls /usr/bin/python* alias: alias python='/usr/bin/pythonxx' (add this to . ~/.bashrc) re-login or source . ~/.bashrc check the python version again: python --version


11

For Ubuntu use sudo apt install libpq-dev


10

A shell is efficient if you use it for what it has been designed for (though efficiency is rarely what you look for in a shell). A shell is a command-line interpreter, it is designed to run commands and have them cooperate to a task. If you want to count to 1000000000, you invoke a (one) command to count, like seq, bc, awk or python/perl... Running ...


10

python36u is an alternative build provided by IUS; python36 is an EPEL package. yum info python36 python36u will show you different repos for the two, and it's likely that the IUS one has a slightly higher minor version number than the EPEL package. And just to make things even more confusing, there's also Redhat Software Collections, which provide rh-...


9

The issue is that simply executing has('python') in an if-statement causes python3 to be unavailable when vim was compiled with both python/dyn and python3/dyn. The simplest solution is probably just to add something like if exists('py2') && has('python') elseif has('python3') endif to your .vimrc before Vundle loads anything. Then, if you ever ...


9

I was missing libpq-fe.h, which I obtained by installing postgresql-devel sudo yum install postgresql-devel


8

Apparently the issue was related to the opencv-python library. I tried to open a python session and import that module mannually but it produced the same error. I removed that module from pip and installed it again with apt install python3-opencv. It worked.


8

As others have said above in the comments, RHEL 7 and its derivatives depend on Python 2 at a very deep level. You simply cannot safely replace Python 2 with 3. Even if that were not the case, your question is based on an incorrect premise, being that replacing Python 2 with Python 3 is a good idea in the first place. You should always call Python 3 as ...


7

Answer: Bash is much slower than Python. One little example is in blog post Performance of several languages.


6

Unix systems don't really have a “system language”. Unix is a multiuser system and each user is free to pick their preferred language. The closest thing to a system language is the default language that users get if they don't configure their account. The location of that setting varies from distribution to distribution; it's picked up at some point during ...


6

It's very likely that the python command has been hashed and that you need to clear the cache. In order to see what executable is actually being run you can use the type command, e.g.: type -a python Unlike the which command, the type command is aware of hashed programs, as well as aliases and shell functions. For further discussion of which (no pun ...


6

You do not need to uninstall Python 2 in order to install Python 3. apt-get install python3 will install it in parallel. Also, in Ubuntu, the minimal subset of Python provided by python-minimal is an essential package, so uninstalling it could have catastrophic consequences.


6

Create symlink for /usr/bin/python3. In my LinuxMint: # ls -lh /usr/bin/python3 /usr/bin/python lrwxrwxrwx 1 root root 9 ноя 24 2017 /usr/bin/python -> python2.7 lrwxrwxrwx 1 root root 9 сен 6 2017 /usr/bin/python3 -> python3.5 # mv /usr/bin/python /usr/bin/python.bak # cp /usr/bin/python3 /usr/bin/python # python --version Python 3.5.2


6

First check that you have a python3.6 folder? ls /usr/bin/python3.6 If you have "python3.6" folder, you are good to go. Now update-alternatives sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 then update new config for python3 sudo update-alternatives --config python3 Finally, check default python3 version: ...


5

Simply copy paste this code: CFLAGS="-I$(brew --prefix readline)/include -I$(brew --prefix openssl)/include -I$(xcrun --show-sdk-path)/usr/include" \ LDFLAGS="-L$(brew --prefix readline)/lib -L$(brew --prefix openssl)/lib" \ PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs2 \ pyenv install -v 3.6.0


5

Ubuntu 14.04 has the lsb_release.py file installed for Python 2.7 as well and lsb_release seems to work under python2.7 as well. You can try this by doing: python2.7 /usr/bin/lsb_release If that works, make a backup of the file /usr/bin/lsb_release and change the first line to read: #! /usr/bin/python2.7 (you can experiment with the -Es options, I would ...


5

Your system may not be looking in /usr/local/lib by default for shared libraries. When you compile things, set the environment variable: export LD_RUN_PATH=/usr/local/lib This is only needed when you compile things. That or add /usr/local/lib to the directories searched by the system for shared libraries.


5

There is a command line option that suits your needs: #!/usr/bin/env python3 -E -E Ignore all PYTHON* environment variables, e.g. PYTHONPATH and PYTHONHOME, that might be set.


5

As is typical with some of the modules in ansible you have to install certain Python modules on the remote server's side. https://github.com/ansible/ansible/issues/21416 You can use the pip module to facilitate this through your ansible playbook like so: - name: install pexpect pip: name: pexpect become: yes Your distro may have these available ...


5

As you can see in your question “/usr/bin/python3 -> python3.6”, python3 is a symlink to python3.6. It uses next to no space. Python3 will be a link to the latest python3.x than you have installed. You could remove the link, but don't you will break something. It may appear that you have two pythons installed /usr/bin/python3.6 and /usr/bin/python3.6m. ...


Only top voted, non community-wiki answers of a minimum length are eligible