Cannot install python3.6 on Debian 4.9 VM - python-3.x

I'm running a Debian VM (4.9.189-3+deb9u1) on the Google cloud. I want to run a script on this instance; the script works fine on my local machine (Mac OSX Mojave 10.14.6; python 3.6.8). However, when I run it on the VM I get an error that seems to relate to the fact that my the VM runs python 3.4 when the script needs python 3.6+.
Here's the problem. When I run python -V, the response is Python 3.7.4. However, when I try to install the library supporting the script I want to run
pip3 install --user --upgrade -e
git+https://github.com/twintproject/twint.git#origin/master#egg=twint
I get
twint requires Python '>=3.6.0' but the running Python is 3.5.3.
I have tried changing the default python as detailed here; this doesn't seem to work––in fact, python 3.6 isn't even visible as an option when I query ls /usr/bin/python*. Can anyone offer some advice on how to proceed here? Thanks.

It seems like you have multiple Python versions available. If python -V gives you Python 3.7.4, you can use:
$ python -m pip install --user --upgrade -e git+https://github.com/twintproject/twint.git#origin/master#egg=twint
to invoke pip from that same Python interpreter.

Related

What’s the difference between python and python3

I’m following some instructions to configure my pc to coding some solidity sample projects and the instructions tell me to install pip and pipx, but first I need to check the version of Python installed. The instructions say to run this at the command prompt:
python3 --version
but when I do, I get the following error:
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
However, if I run:
Python --version
It returns: Python 3.8.5
So when I’m instructed to run “python3” …. Is that an apple syntax where I would use just “python” for windows? I’ve googled this and could not find any clarification.
Thank you.
Often in reading instructions for installing things in Python, we see syntax like this:
python3 --version
but on my PC I get an error "Cannot find python3" even though I have python 3.7, 3.8 and 3.9 installed.
For me using this syntax worked:
python --version
python -m pip install --user pipx
python -m pipx ensurepath

python2 and python3 on Ubuntu

I recently installed Ubuntu 18.04.4 which came with Python 3.7.6 installed. I installed Atom v1.45, which comes with Python 2.7 automatically.
When running a Python script from the terminal, it raises ModuleNotFoundError. I figured that if I ran the script from the terminal with python3.7 file.py instead of python file.py there is no problem, though it is slightly annoying to do that all the time.
I uninstalled python2.7 but then I could not use Atom.
How can solve this problem?
I faced a very similar problem. Some of the tips from my end are:
I recommend using a virtual environment when running scripts from the command-line. This helps resolve all module dependencies for the script in general and especially when dealing with multiple Python versions.
$ virtualenv -p /usr/bin/python3 ./venv
$ source ./venv/bin/activate
$ ./venv/bin/python foo.py
Typically, the above steps, are either in my Makefile or in a helper script.
When running a script from the terminal, if you want to type python instead of python3.7, you can create a symlink for python to point to python3 in the /usr/bin directory.
Also, I recommend switching to python3 completely since support for python2.7 has officially stopped.

Spyder Kernels "module not found" on Ubuntu VM

I am trying to connect a spyder kernel with my remote Ubuntu machine and was following this guide. Installing spyder kernels using sudo pip install spyder-kernels worked fine.
However, when trying to run:
python -m spyder_kernels.console — matplotlib=’inline’ — ip=my.vm.ip.address. -f=./remotemachine.json
I receive the following error on my VM:
Error while finding module specification for 'spyder_kernels.console' (ModuleNotFoundError: No module named 'spyder_kernels')
My remote VM uses Python 3.7.7 and is hosted by Google's cloud platform.
Any help much appreciated.
The issue is that running sudo pip install, you're using the root user's Python installation, and not the user installation you eventually run your command from.
Try using either python -m pip install spyder-kernels or sudo python -m spyder_kernels.console .... Preferably you would not run either command as root.

Why virtualenv shows all packages installed and do not install modules in virtualenv?

Question
I am not sure why when virtualenv active, pip freeze stills showing all modules when it suppose NOT to. What am I doing wrong?
On the terminal
I tried two ways to create a virtual env:
virtualenv my-virtualenv
virtualenv --no-site-packages my-virtualenv
then activate it
source my-virtualenv/bin/activate
Results
Both show all packages (when they suppose not to). Running command pip freeze I get:
(my-virtualenv)$ pip freeze
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
actionlib==1.11.9
angles==1.9.11
bondpy==1.7.19
camera-calibration==1.12.20
camera-calibration-parsers==1.11.12
catkin==0.7.6
cv-bridge==1.12.4
diagnostic-analysis==1.9.2
diagnostic-common-diagnostics==1.9.2
diagnostic-updater==1.9.2
dynamic-reconfigure==1.5.48
gazebo-plugins==2.5.13
gazebo-ros==2.5.13
...
rosnode==1.12.7
rosparam==1.12.7
rospy==1.12.7
rosservice==1.12.7
rostest==1.12.7
rostopic==1.12.7
rosunit==1.13.5
roswtf==1.12.7
tf2-ros==0.5.16
topic-tools==1.12.7
xacro==1.11.2
Running
(my-virtualenv)$ which python
/home/user/.../my-virtualenv/bin/python
(my-virtualenv)$ python -V
Python 2.7.12
and
(my-virtualenv)$ which python3
/usr/bin/python3
(my-virtualenv)$ python3 -V
Python 3.5.2
Hence, I even can use python3 when virtualenv is activated but it uses the pc installed module. Moreover, new installed packages are install in the pc and not the virtualenv and I can't install python3 in the vitualenv because it "exists" already (but in the pc).
I was having the same issue and it was because, somehow, Python configuration of ROS was generating it.
I solved it removing the source commands of ROS from the ~/.bashrc. E.g.:
source /opt/ros/melodic/setup.bash
source $HOME/ROS/aslam_ws/devel/setup.bash
By the way, I realised that, before changing anything, creating the environment from PyCharm works properly too (when in the terminal I still had the issue).
There must be a better solution but I haven't found it yet.

How to set running python as pyhton3.6 in ubuntu?

While installing a project requirement file (pip install -r requirements.txt) terminal is giving this error:
css-html-js-minify requires Python '>=3.6' but the running Python is 2.7.12
I think the issue is due to the library “css-html-js-minify” which requires a Python version >= 3.6.
Try using pip3.
Note that on some Linux distributions including Ubuntu and Fedora the pip command is meant for Python 2, while the pip3 command is meant for Python 3.
Installing Python on Linux.

Resources