Import "telegram" could not be resolved (on MacOS) - python

I try to install pyhon-telegram-bot on macOS.
python -i
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.
But even though the terminal says that I have successfully installed ptb, I get an import error.
Import "telegram" could not be resolved Pylance(reportMissingImports)
And also when checking for the installed version, it says no module not found:
/usr/bin/python: No module named telegram
I used the correct command:
pip3 install python-telegram-bot
I run out of ideas to be honest.
On my Windows PC (at home) all works fine.
I ptb only working on Windows machines?

Related

How can I install data.table on my fedora distro

Looking at this github I'd like to be able to install datatable.
I do run a fedora 26 distro that runs python3.6
statquant  ~  python3
Python 3.6.4 (default, Mar 13 2018, 18:16:01)
[GCC 7.3.1 20180130 (Red Hat 7.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
When I try to install it I get:
statquant  ~  pip install https://s3.amazonaws.com/h2o-release/datatable/stable/datatable-0.3.2/datatable-0.3.2-cp36-cp36m-linux_x86_64.whl
datatable-0.3.2-cp36-cp36m-linux_x86_64.whl is not a supported wheel on this platform.
Is this expected ?
I am totally new to python
Currently Python datatable distributes pre-built binaries for the following platforms:
MacOS
CentOS Linux (linux_x86_64)
PowerPC Linux (ppc64le)
For all other platforms, you would have to clone the repository and manually build from source.

With Python 2.7.15 on a MAC console, virtualenv creates an environment with a different version of Python

Here is an extract of my console in a Mac, as you can see the Python on the console is 2.7.15 but on the environment it becomes 2.7.10 which is an older version... any help on why and how to fix it would be most welcomed!
dhcp-18-57:Wakeup6 **jbs$ python**
**Python 2.7.15** (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
dhcp-18-57:Wakeup6 jbs$ virtualenv env
New python executable in /Users/jbs/PycharmProjects/Wakeup6/env/bin/python
Installing setuptools, pip, wheel...done.
dhcp-18-57:Wakeup6 jbs$ source env/bin/activate
(env) dhcp-18-57:Wakeup6 **jbs$ 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.
>>> exit()
If you installed python using Anaconda, then set up a new virtual environment for python 2.7.15 Then following directions in the Anaconda documentation, activate this virtual environment and you should be good to go.
If you didn't use Anaconda, just follow the directions for setting up a virtual environment on a Unix box. Then activate that environment and start working.
You can have multiple versions on your computer. Virtual environments allow you to run the version you want. I have virtual environments for python 2.7.13 and python 3.6.
If this doesn't work please let me know. I'll try to help.
Thank you all for your input. I finally figured out how to solve it. The difficult part was finding out how to locate the place where python 2.7.15 was installed which I'll leave intact in the response since I found it by trial and error looking in other places. I have not found a command that gives you the full path (perhaps an expert can tell us how to go from the laconic which python to the full path).
What I find interesting is that it does not really matter what the console uses when calling virtualenv. What matters is the version of Python used to install virtualenv which is the default version that will be used.
Essentially one has to use the -p option in virtualenv and make sure to find the right location where the desired version of python is.
dhcp-18--41:WakeUp8 jbs$ virtualenv -p /usr/local/Cellar/python#2/2.7.15/bin/python env
Running virtualenv with interpreter /usr/local/Cellar/python#2/2.7.15/bin/python
New python executable in /Users/jbs/PycharmProjects/WakeUp8/env/bin/python2.7
Also creating executable in /Users/jbs/PycharmProjects/WakeUp8/env/bin/python
Installing setuptools, pip, wheel...done.
dhcp-18-189-34-41:WakeUp8 jbs$ python
Python 2.7.15 (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
dhcp-18--41:WakeUp8 jbs$ pwd
/Users/jbs/PycharmProjects/WakeUp8
dhcp-18-189-34-41:WakeUp8 jbs$ source env/bin/activate
(env) dhcp-18-189-34-41:WakeUp8 jbs$ python
Python 2.7.15 (default, May 1 2018, 16:44:14)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

I can only import the Stripe Python library under a certain version of Python

I use Webfaction, and this is the command line for the shared host.
[zallarak#web198 ~]$ python2.6
Python 2.6.5 (r265:79063, Nov 23 2010, 02:02:03)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import stripe
>>>
[zallarak#web198 ~]$ python2.7
Python 2.7.1 (r271:86832, Dec 1 2010, 06:29:57)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import stripe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named stripe
I know there must be a simple way to make it work in all version of Python. I would much appreciate any insight on how to make this work/the concept behind it.
My version of Django runs on 2.7, so the goal is to make it work on 2.7
Your problem is that the stripe module is not installed in each python environment.
I know there must be a simple way to make it work in all version of Python.
You must install stripe in each environment. According to your webhost, you should be able to install them with easy_install. Try this:
python2.7 `which easy_install` stripe
Brian Cain is correct about it not being installed in the Python version you are using. Instead of the command he gave you should run:
easy_install-2.7 stripe
After making sure that the directory: /home/username/lib/python2.7/ actually exists. If it doesn't you can use the command: mkdir -p /home/username/lib/python2.7 to create it.
That will install it in your Python2.7 installation, which you can then use from Django on Python2.7.
Note: If you get the error: "Need libcurl version 7.19.0 or greater to compile pycurl." you'll need to follow the instructions here:
http://community.webfaction.com/questions/6365/problems-installing-pycurl
to install your own version of curl on your account.

MacPorts on Snow Leopard: Python install seems to succeed but doesn't install a non-system Python

I've installed Python via MacPorts. According to this question, the files in /opt/local/bin should run the "correct" Python version. However, all those files are symlinks to:
/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin/
Running them directly from that folder (using no symlinks) runs an Apple build of Python!
Python 2.6.6 (r266:84292, Jan 6 2011, 13:25:25)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
For comparison, running /usr/bin/python shows a slightly different version:
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
They're both Apple builds! How do I install the correct version?
There are no "Apple builds" except the system Python (which is 2.6.1 on Snow Leopard, afai can deduce). The ports install seems to have worked as expected in this case. The reference to Apple is a reference to which GCC that was used.
I think it is running the build you want.
macports install every thing in /opt/local. So /opt/local/bin/python is a macport distribution.
/usr/bin/python is pre-install python distribution that comes with mac os x.
The following line, is an information about gcc build which is used for building macport python distribution.
[GCC 4.2.1 (Apple Inc. build 5664)]
If you have multiple versions of macport python installed, you can select the version using python-select
sudo port install python-select sudo
python-select python26
Also to ensure that you use macport python you could add the following to the PATH
export PATH=/opt/local/bin:$PATH

How to install Python 3.1.2 on Mac OS X 10.6.4?

Hi there I have downloaded the mac installer here, http://www.python.org/download/releases/3.1.2/ , & installed it. But when I run terminal & type python it says:
Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
What I want to know is, is it safe to run Update Shell Profile.command in the Python 3.1 folder ? or should I run python 3.1.2 separately ? If I should run python 3.1.2 separately, how do I do so ? also how do I start IDLE ?
Is there another python executable, perhaps python31?
You can also install other python versions via MacPorts if you need (although you'll still have to choose the right executable).
This should also be relevant: Multiple versions of Python on OS X Leopard

Categories

Resources