cannot install library python - python

i want to install the library telethon
It says i should execute this line of code
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade telethon
The first command works, it has a bunch of warnings but it seems to work.
But the second command says:
ERROR: Could not find a version that satisfies the requirement telethon (from versions: none) ERROR: No matching distribution found for telethon
So what i am doing wrong?
I am using windows

To install a virtual env and your package:
$ python --version
Python 3.6.9
$ python -m venv venv
$ source venv/bin/activate
(venv)$ pip install -U pip setuptools
(venv)$ pip install telethon
(venv)$ python
Python 3.6.9 (default, Jun 13 2020, 20:27:45)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.32.62)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Now try to load telethon:
>>> import telethon
>>> telethon.__version__
'1.23.0'

I have found the solution:
I just have to run VS code editor as "admin"

Related

How to install pyaudio module in the current version of python while having multiple versions of python installed?

I have installed multiple versions of python like 3.8.5 and 3.9.2 in my Linux Ubuntu system. I want to install pyaudio module in 3.9.2 version.
For this, I have used a command: pip3 install PyAudio and I am getting this error - error: Microsoft Visual C++ 14.0 is required.
I have also used python unofficial libraries and tried to install pyaudio but it shows this error -
ERROR: PyAudio-0.2.11-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.
Then I used these commands for the same -
sudo apt-get install libasound-dev portaudio19-dev libportaudio2
libportaudiocpp0
sudo apt-get install ffmpeg libav-tools
sudo pip install pyaudio
After this when I import pyaudio module, it shows module not found error. But when I tried to re-install the module, it shows requirement already satisfied.
Then I executed the command:
sudo -s
python3
import pyaudio
Now it shows no error. It seems that pyaudio module has been installed in python 3.8.5 version and not in python 3.9.2 version. However, I used virtual environment of older python version and installed speech recognition, pyaudio which worked well.
I want to use pyaudio module without using virtual environment without any errors. Please help.
Here is the screenshot of the issueimage_pyaudio_issue
Here is the code -
maaz#maaz-HP-Notebook:~$ python
Python 2.7.18 (default, Mar 8 2021, 13:02:45)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import pyaudio
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named pyaudio
import PyAudio
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named PyAudio
exit()
maaz#maaz-HP-Notebook:~$ sudo pip install pyaudio
[sudo] password for maaz:
Requirement already satisfied: pyaudio in /usr/lib/python3/dist-packages (0.2.11)
maaz#maaz-HP-Notebook:~$ sudo -s
[sudo] password for maaz:
root#maaz-HP-Notebook:/home/maaz# python3
Python 3.8.5 (default, May 27 2021, 13:30:53)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import pyaudio
exit()
root#maaz-HP-Notebook:/home/maaz# exit
exit
Check in the usr/bin and usr/local/bin for all python instances.
The installation of python3 is probably linked to python 3.8.5. But there might be a python3.9.
You could check for other python instances in the above folders by running the below commands:
ls -ls /usr/bin/python*
ls -ls /usr/local/bin/python*
If so, you can run the commands with python3.9, but i would recommend cleaning up the unused installations.

ModuleNotFoundError: No module named 'jpype'

I am using Anaconda Python and used the following to install jpype:
conda install -c conda-forge jpype1
I have GCC installed:
Python 3.6.1 |Anaconda 4.4.0 (x86_64)| (default, May 11 2017, 13:04:09)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
and I did not get any error during installation.
conda install -c conda-forge jpype1
Collecting package metadata: done
Solving environment: done
# All requested packages already installed.
If I run pip search jpype I will get the following:
jtypes.jpype (0.6.3b3) - A Python to Java bridge (ctypes/cffi-based JPype).
JPype1-py3 (0.5.5.2) - Python-Java bridge. Fork of the jPype project by Steve Menard (http://jpype.sourceforge.net/), with the modifications applied by Luis Nell
(https://github.com/originell/jpype)
but still cannot call the library
>>> import jpype
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'jpype'
It might be because it is installed as a Python 2 package and you're running Python 3 or the opposite.
To specifically install the package for Python 3, try entering this command:
pip3 install jpype1
or
python3 -m pip install jpype1
To specifically install the package for Python 2, try entering this command:
pip2 install jpype1
or
python -m pip install jpype1
I found the problem.
By mistake, I had two versions of Anaconda 3.6 and 3.7 which was causing the problem.

pip freeze doesn't show opencv in Linux/Mint

I've installed OpenCV on Linux Mint and I can import it in python
(cv_env)➜ cv_env python
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv
>>> import cv2
>>> import numpy
>>> import scipy
But when I want to see it in pip freeze, it doesn't appear:
(cv_env)➜ cv_env pip freeze
argparse==1.2.1
caffi==1.0.2
coffee==0.1.0
ffmpeg-python==0.1.6
future==0.16.0
imutils==0.4.3
numpy==1.13.3
pandas==0.20.3
python-dateutil==2.6.1
pytz==2017.2
scipy==0.19.1
six==1.11.0
wsgiref==0.1.2
Also, I tried to import it via PyCharm's Project Interpreter. It wants to installation with pip. (pip install opencv-python and pip install cv2)
When I installed that, I followed these steps
What is the problem that I cannot see?
Those instructions are outdated, and using apt-get puts pieces outside of the virtual environment, where pip won't see them to freeze.
Within a virtual environment, try
pip install --upgrade pip
pip install opencv-python
The --upgrade might not be necessary, but has helped me out of weird pip failures in the past.

Brew is not able to find dependency in spite of it being installed

Brew is not able to find dependency inspite of it being installed.
dependency 'urllib2_kerberos' is already installed yet homebrew throws the message
Homebrew does not provide special Python dependencies; install with: pip install urllib2_kerberos
Here are the setup steps:
$ sudo pip2.7 install urllib2_kerberos
Requirement already satisfied (use --upgrade to upgrade):
urllib2_kerberos in
/usr/local/lib/python2.7/site-packages/urllib2_kerberos-0.1.6-py2.7.egg
$ sudo pip2.7 install urllib2_kerberos --upgrade
Requirement already up-to-date: urllib2_kerberos in
/usr/local/lib/python2.7/site-packages/urllib2_kerberos-0.1.6-py2.7.egg
$ brew install post-review
post-review: Unsatisfied dependency: urllib2_kerberos Homebrew does
not provide special Python dependencies; install with: pip install
urllib2_kerberos Error: An unsatisfied requirement failed this build.
Also tried
$ /usr/local/bin/python2.7
It successfully imports
Python 2.7.12 (default, Jun 29 2016, 14:04:44) [GCC 4.2.1 Compatible
Apple LLVM 7.0.2 (clang-700.1.81)] on darwin Type "help", "copyright",
"credits" or "license" for more information.
>>> import urllib2_kerberos
(Note: post-review is not on http://braumeister.org/ .
I tapped into another formula repo)
Just encountered this problem myself. The solution is making sure the dependencies are available in your path.
In my case, I'm running with Anaconda Python and had anaconda2/bin in my path but not anaconda2/lib.
I added the following to my zshrc:
export PATH="/Users/$ME/anaconda2/lib/python2.7/site-packages:/Users/$ME/anaconda2/lib/python2.7:/Users/$ME/anaconda2/lib:$PATH"
Then source ~/.zshrc (or your respective shell resource file) and you're good.

How do I install python3-gi within virtualenv?

I'm following the Python GTK+ 3 Tutorial and I'm trying to get a working install running in virtualenv. I have python3-gi installed through the Ubuntu package manager already. Things look like this:
:~$ mkvirtualenv py3 --python=/usr/bin/python3
Running virtualenv with interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in py3/bin/python3
Also creating executable in py3/bin/python
Installing setuptools, pip...python
done.
(py3):~$ python
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'gi'
>>>
(py3):~$ deactivate
:~$ /usr/bin/python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>>
As you can see, python3-gi is obviously not available within virtualenv but I am not sure how to install it since python3-gi is installed through my package manager and not with pip.
It is now possible to resolve this using vext. Vext allows you to install packages in a virtualenv that individually access your system packages. To access gi, do the following:
pip install vext
pip install vext.gi
Update 2018 – Debian Stretch
Install GTK+ 3 / GIR.
apt install libcairo2-dev libgirepository1.0-dev gir1.2-gtk-3.0
Create a virtual environment.
python3 -mvenv venv
Install pygobject (pycairo should come as a dependency).
venv/bin/pip install pygobject
Update 2018 – macOS
Install GTK+ 3 and Gobject Introspection with Homebrew.
brew install gtk+3 gobject-introspection
Create and activate a virtual environment.
python3 -mvenv venv
Install pygobject (pycairo should come as a dependency).
PKG_CONFIG_PATH=/usr/local/opt/libffi/lib/pkgconfig ARCHFLAGS="-arch x86_64" venv/bin/pip install pygobject
Original answer
This is what I did to get GTK+ 3 within a Python 3.5 virtual environment on OS X 10.11.
Install GTK+ 3 with Homebrew.
brew install gtk+3
Create and activate a virtual environment.
pyvenv-3.5 venv
source venv/bin/activate
cd venv
Install pycairo on the virtual environment.
export PKG_CONFIG_PATH=$VIRTUAL_ENV/lib/pkgconfig
curl -L https://cairographics.org/releases/pycairo-1.10.0.tar.bz2 | tar xj
cd pycairo-1.10.0
export ARCHFLAGS='-arch x86_64'
python waf configure --prefix=$VIRTUAL_ENV # It's ok, this will fail.
sed -i '' '154s/data={}/return/' .waf3-1.6.4-*/waflib/Build.py # Bugfix: https://bugs.freedesktop.org/show_bug.cgi?id=76759
python waf configure --prefix=$VIRTUAL_ENV # Now it should configure.
python waf build
python waf install
unset ARCHFLAGS
cd ..
Install pygobject on the virtual environment.
export PKG_CONFIG_PATH=$VIRTUAL_ENV/lib/pkgconfig:/usr/local/opt/libffi/lib/pkgconfig
curl -L http://ftp.gnome.org/pub/GNOME/sources/pygobject/3.12/pygobject-3.12.2.tar.xz | tar xJ
cd pygobject-3.12.2
./configure CFLAGS="-I$VIRTUAL_ENV/include" --prefix=$VIRTUAL_ENV
make
make install
cd ..
Profit.
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.
>>> from gi.repository import Gtk, Gdk, Pango, GObject
>>> from cairo import ImageSurface, Context, FORMAT_ARGB32
>>>
Python 3.5 downloaded and installed from PSF.
I haven't found a proper solution to this. When I run into situations where I can't get something to install into a virtualenv directly, I symlink it there and it works fine (there are probably exceptions, but this is not one of them).
ln -s /usr/lib/python3/dist-packages/gi /path_to_venv/lib/python3.4/site-packages/
Not elegant in the slightest; seems nicer than giving the virtualenv full access to all system packages though (via --system-site-packages).
The pip package name is somewhat counterintuitive - use pip install PyGObject.
I installed pgi via pip, which may be an option. It is apparently API compatible with PyGObject and so far seems to work ok running Gtk.
On Ubuntu (tested in 19.04), you can download the package and then install it as follows:
apt-get -y download python3-gi
dpkg-deb -x <package>.deb <virtualenv path>
In Ubuntu, the name of the downloaded package is python3-gi_3.32.0-1_amd64.deb.

Categories

Resources