How do I install python-telegram-bot to python 3.10.1? - python

After running pip3 install python-telegram-bot in command prompt, I get 'telegram' module is not found when I run python -m telegram after the installation.
I have Python 3.9 and 3.10.1 installed, and it seems like the package is installed in the Python 3.9 directory as the output during the installation shows ...pythonsoftwarefoundation.python.3.9
I am new to programming, so I am at a lost as to how to install it for Python 3.10.1. Appreciate any guidance I can get.

Since you installed the module through pip3 there is a chance you just need to use python3. Try python3 -m telegram.
Opposite it might be that you need to use pip install python-telegram-bot for it to work with python.
Usually pip is linked to python and pip3 is linked to python3 but it is only a guideline, not a rule.
If that doesn't work you can always invoke pip for the other python binary with python -m pip install python-telegram-bot

Related

How to Install virtualenv without pip?

I have a problem on pip.
As I use pyenv, using python version 3.7.x, there is no problem around pip.
$ /home/yuis/.pyenv/shims/pip --version
pip 19.2.3 from /home/yuis/.pyenv/versions/3.7.6/lib/python3.7/site-packages/pip (python 3.7)
But using python version 3.6.x, I get a result that saying the pip is located on "~/.local", but not on "~/.pyenv".
This is very bad for me. Because the version what I need now is 3.6.x.
This incomprehensive pip behavior continues if I install other python 3.6 version, so python 3.6.12 and 3.6.11 will show this same path.
I guess this bug is most probably because some kind of conflict from the locally installed python and pyenv installed one.
$ /home/yuis/.pyenv/shims/pip --version
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 20.3.3 from /home/yuis/.local/lib/python3.6/site-packages/pip (python 3.6)
Now, I don't care much about pip anymore, because it seems an unsolvable issue. No time to waste. So now I want to try with virtualenv.
I need to install virtualenv first, because I can see this error.
$ virtualenv venv
pyenv: virtualenv: command not found
The `virtualenv' command exists in these Python versions:
3.5.10
3.7.6
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
But both of the followings didn't work.
pip install virtualenv
/home/yuis/.pyenv/shims/pip install virtualenv
python -m pip install virtualenv
Now I have no idea what is going on on my machine and how to solve this problem.
Have you tried python -m virtualenv .venv?
Try this maybe,
pip install git+https://github.com/pypa/virtualenv.git#main
You can visit this link for further details,
Also make sure your python & conda env are properly configured and added to PATH

I have python 2.7 and 3.6 installed on my mac. How to find the version of pip associated with Python3?

I tried using pip --version but it will give me the version of only pip associated with python and not python3.
Try using pip3 --version. Normally pip3 is the symlink to the pip associated with Python3. If that doesn't work, please provide more details as to how you installed the python versions.
You can run the following command, where you can update the program python to whatever python program you have
python -m pip --version

ImportError: No module named mako.util when running airflow

I'm trying to follow the tutorial on here: http://pythonhosted.org/airflow/tutorial.html
but i'm using a mac, and so i had to install python via brew, which then comes with pip, which i used to install airflow. However, that didn't quite work either, so i then tried to create a virtualenv for which i tried to install airflow and it is still giving me this ImportError: No module named mako.util
not sure if it matters, but here's my setup:
(airflow) [davidtian: airflow]$ python --version
Python 2.7.12
(airflow) [davidtian: airflow]$ pip --version
pip 8.1.2 from /Users/someone/Desktop/blah/airflow/airflow/lib/python2.7/site-packages (python 2.7)
(airflow) [davidtian: airflow]$
How do i install this mako.util module?
Finally figured it out. after trying a bunch of things. for one, the python that comes with Mac apparently doesn't work very well. you have to brew install python instead. with that python, it comes with pip by default
i had to actually sudo pip uninstall airflow and then install it again.

How to use pip with python3.5 after upgrade from 3.4?

I'm on Ubuntu and I have python2.7, (it came pre-installed) python3.4, (used before today) and python3.5, which I upgraded to today, installed in parallel. They all work fine on their own.
However, I want to use pip to install some packages, and I can't figure out how to do this for my 3.5 installation because pip installs for 2.7 and pip3 installs python 3.4 packages.
For instance, I have asyncio installed on 3.4, but I can't import it from 3.5. When I do pip3 install aysncio, it tells me the requirement is already satisfied.
I'm a bit of a newbie, but I did some snooping around install directories and couldn't find anything and I've googled to no avail.
I suppose you can run pip through Python until this is sorted out. (https://docs.python.org/dev/installing/)
A quick googling seems to indicate that this is indeed a bug. Try this and report back:
python3.4 -m pip --version
python3.5 -m pip --version
If they report different versions then I guess you're good to go. Just run python3.5 -m pip install package instead of pip3 install package to install 3.5 packages.
Another way would be to setup a virtual environment:
$ python3.4 -m venv envdir
$ source envdir/bin/activate
$ pip --version
Obviously, this won't install the packages globally and you'll have to source venv/bin/activate every time you wan to make use of it.

how to manage multiple Python distributions on one device

I have a macbook pro, and I have Python 2.7,3.3 and 3.4 and Anaconda 2.7 installed, and I am having a hard time managing all these multiple Python distributions. These are the problems I am facing :
pip install installs for anaconda 2.7 by default, how do I make it install for PYthon 2.7 ?
how do I make pip3 install work for different Python distributions? i.e is there some way I can use something like pip3 install -v 3.3.6 or something similar.
how do I find a workaround for these problems. I wish to know the answer in both the basic sense (how Python and Anaconda work, and what happens when I use pip install, and how do I use these to solve my problem), and also in the practical sense (is there some simple way to manage this problem).
To install packages for specific python versions, it is easiest to run python with the -m flag. The -m flag will run the specified module as a script. Calling python -m pip install _package_ will run pip for whatever python you specify.
Examples:
python -m pip install _package_
python3 -m pip install _package_
python2.7 -m pip install _package_
python3.7 -m pip install _package_

Categories