I have installed pydispatch using - pip install pydispatch - in cmd
C:\Users\masysna1\Desktop\aswath-hiwi\cortex-v2-example-master\Demo>pip install pydispatch
Requirement already satisfied: pydispatch in c:\users\masysna1\appdata\local\programs\python\python310\lib\site-packages (1.1.0)
Requirement already satisfied: six>=1.5.2 in c:\users\masysna1\appdata\local\programs\python\python310\lib\site-packages (from pydispatch) (1.16.0)
Requirement already satisfied: colorama>=0.2.7 in c:\users\masysna1\appdata\local\programs\python\python310\lib\site-packages (from pydispatch) (0.4.4)
but when I run from pydispatch import Dispatcher in python. I get the following error
ImportError: cannot import name 'Dispatcher' from 'pydispatch'
before this was working fine, can anyone help me
Use pip install python-dispatch.
haiii i am running python code in ubuntu 18.04
i needed opencv libarary for the code so i installed opencv using python3
pip3 install opencv-python
but the code requires and compatible with python 2
so i tried to install the library using just pip instead of pip3
when i tried to install opencv using pip it is saying
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: opencv-python in /home/sri/.local/lib/python3.6/site-packages (4.4.0.46)
Requirement already satisfied: numpy>=1.13.3 in /home/sri/.local/lib/python3.6/site-packages (from opencv-python) (1.19.4)
but running my file python train.py shows no module named cv2
some body please help me to solve this problem
same going with my pytorch library also
Traceback (most recent call last):
File "train.py", line 6, in <module>
from model import CANNet
File "/home/sri/Downloads/Context-Aware-Crowd-Counting-master/model.py", line 1, in <module>
import torch.nn as nn
ImportError: No module named torch.nn
so i tried installing pytorch
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio==0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Defaulting to user installation because normal site-packages is not writeable
Looking in links: https://download.pytorch.org/whl/torch_stable.html
Requirement already satisfied: torch==1.7.0+cpu in /home/sri/.local/lib/python3.6/site-packages (1.7.0+cpu)
Requirement already satisfied: torchvision==0.8.1+cpu in /home/sri/.local/lib/python3.6/site-packages (0.8.1+cpu)
Requirement already satisfied: torchaudio==0.7.0 in /home/sri/.local/lib/python3.6/site-packages (0.7.0)
Requirement already satisfied: numpy in /home/sri/.local/lib/python3.6/site-packages (from torch==1.7.0+cpu) (1.19.4)
Requirement already satisfied: future in /home/sri/.local/lib/python3.6/site-packages (from torch==1.7.0+cpu) (0.18.2)
Requirement already satisfied: dataclasses in /home/sri/.local/lib/python3.6/site-packages (from torch==1.7.0+cpu) (0.8)
Requirement already satisfied: typing-extensions in /home/sri/.local/lib/python3.6/site-packages (from torch==1.7.0+cpu) (3.7.4.3)
Requirement already satisfied: pillow>=4.1.1 in /home/sri/.local/lib/python3.6/site-packages (from torchvision==0.8.1+cpu) (8.0.1)
You are troubleshooting with your versions. You say your code is not workable for python3 so you tried to run it on python2. It seems that your pip is linking against your python 3.6 Version instead of python 2.X. The best way to handle these problems are virtual environments:
Python 3.X: https://docs.python.org/3/library/venv.html
Python 2.X: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/
Inside an activated Environment the command python and pip are linked to the version of the environment.
I had a code that I was able to run last year using Google Cloud Natural Language. I am not able to this year due to a library problem. I used the following methods to install it. However, not successful. How should install it?
[jalal#goku sentiment]$ pip install --user --upgrade google-cloud
Collecting google-cloud
Downloading https://files.pythonhosted.org/packages/ba/b1/7c54d1950e7808df06642274e677dbcedba57f75307adf2e5ad8d39e5e0e/google_cloud-0.34.0-py2.py3-none-any.whl
Installing collected packages: google-cloud
Successfully installed google-cloud-0.34.0
[jalal#goku sentiment]$ python sentiment.py
Traceback (most recent call last):
File "sentiment.py", line 20, in <module>
from google.cloud import language
ModuleNotFoundError: No module named 'google.cloud'
[jalal#goku sentiment]$ python -m pip install google-cloud
Requirement already satisfied: google-cloud in /home/grad3/jalal/.local/lib/python3.6/site-packages (0.34.0)
The error is:
$ python sentiment.py
Traceback (most recent call last):
File "sentiment.py", line 20, in <module>
from google.cloud import language
ModuleNotFoundError: No module named 'google.cloud'
A little about my system setup:
$ which python
/scratch/sjn-p3/anaconda/anaconda3/bin/python
$ python
Python 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 18:10:19)
[GCC 7.2.0] on linux
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.6.1810 (Core)
Release: 7.6.1810
Codename: Core
Also, I find it very weird when I am installing the pip package with Anacoda pip why does it install it into native Python and not Anaconda Python?
$ /scratch/sjn-p3/anaconda/anaconda3/bin/pip install --user --upgrade google-cloud
Requirement already up-to-date: google-cloud in /home/grad3/jalal/.local/lib/python3.6/site-packages (0.34.0)
The issue is you are using the --user flag and pip but wish to run the Anaconda distribution of Python.
If you do python -c 'import site; print(site.USER_BASE)' from the CLI it will return /home/grad3/jalal/.local hence why packages are installed there when you pass the --user flag to pip. Since you want to use the Anaconda distribution you should stay consistent and use their version of a package manager, which would be conda in this case, which you can find about more --> here.
However, I highly recommend using virtual environments so that this issue can be avoided in the future. You can find out more about Anaconda virtual environments over --> here.
If you wish to keep using pip along with Anaconda you can modify your target directory in the ~/.pip/pip.conf file to point at the location you want. Probably something along these lines will work:
[global]
target=/scratch/sjn-p3/anaconda/anaconda3/lib/python{version}/site-packages
Solved the problem by the following command. You have to install the specific product from the Google Cloud (in this case Natural Language):
$ pip install --user --upgrade google-cloud-language
Collecting google-cloud-language
Using cached https://files.pythonhosted.org/packages/b1/3a/6f5808421aea97363cb19a095f73ed6eed12bbaee1e67f2145af7125585d/google_cloud_language-1.1.1-py2.py3-none-any.whl
Collecting google-api-core[grpc]<2.0.0dev,>=1.6.0 (from google-cloud-language)
Using cached https://files.pythonhosted.org/packages/7d/73/e4877e921fe59307ec6b1b0b0c2ad9fde2d1c6bab8dd06ec913891a20dc6/google_api_core-1.8.2-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: protobuf>=3.4.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (3.6.1)
Requirement already satisfied, skipping upgrade: pytz in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (2017.3)
Requirement already satisfied, skipping upgrade: six>=1.10.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (1.11.0)
Requirement already satisfied, skipping upgrade: requests<3.0.0dev,>=2.18.0 in /home/grad3/jalal/.local/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (2.21.0)
Collecting google-auth<2.0dev,>=0.4.0 (from google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language)
Using cached https://files.pythonhosted.org/packages/c5/9b/ed0516cc1f7609fb0217e3057ff4f0f9f3e3ce79a369c6af4a6c5ca25664/google_auth-1.6.3-py2.py3-none-any.whl
Collecting googleapis-common-protos!=1.5.4,<2.0dev,>=1.5.3 (from google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language)
Requirement already satisfied, skipping upgrade: setuptools>=34.0.0 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (38.4.0)
Requirement already satisfied, skipping upgrade: grpcio>=1.8.2; extra == "grpc" in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (1.15.0)
Requirement already satisfied, skipping upgrade: idna<2.9,>=2.5 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (2.6)
Requirement already satisfied, skipping upgrade: urllib3<1.25,>=1.21.1 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (1.22)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (2018.10.15)
Requirement already satisfied, skipping upgrade: chardet<3.1.0,>=3.0.2 in /scratch/sjn-p3/anaconda/anaconda3/lib/python3.6/site-packages (from requests<3.0.0dev,>=2.18.0->google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language) (3.0.4)
Collecting pyasn1-modules>=0.2.1 (from google-auth<2.0dev,>=0.4.0->google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language)
Using cached https://files.pythonhosted.org/packages/da/98/8ddd9fa4d84065926832bcf2255a2b69f1d03330aa4d1c49cc7317ac888e/pyasn1_modules-0.2.4-py2.py3-none-any.whl
Collecting cachetools>=2.0.0 (from google-auth<2.0dev,>=0.4.0->google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language)
Using cached https://files.pythonhosted.org/packages/39/2b/d87fc2369242bd743883232c463f28205902b8579cb68dcf5b11eee1652f/cachetools-3.1.0-py2.py3-none-any.whl
Collecting rsa>=3.1.4 (from google-auth<2.0dev,>=0.4.0->google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language)
Using cached https://files.pythonhosted.org/packages/02/e5/38518af393f7c214357079ce67a317307936896e961e35450b70fad2a9cf/rsa-4.0-py2.py3-none-any.whl
Collecting pyasn1<0.5.0,>=0.4.1 (from pyasn1-modules>=0.2.1->google-auth<2.0dev,>=0.4.0->google-api-core[grpc]<2.0.0dev,>=1.6.0->google-cloud-language)
Using cached https://files.pythonhosted.org/packages/7b/7c/c9386b82a25115cccf1903441bba3cbadcfae7b678a20167347fa8ded34c/pyasn1-0.4.5-py2.py3-none-any.whl
Installing collected packages: pyasn1, pyasn1-modules, cachetools, rsa, google-auth, googleapis-common-protos, google-api-core, google-cloud-language
The scripts pyrsa-decrypt, pyrsa-encrypt, pyrsa-keygen, pyrsa-priv2pub, pyrsa-sign and pyrsa-verify are installed in '/home/grad3/jalal/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed cachetools-3.1.0 google-api-core-1.8.2 google-auth-1.6.3 google-cloud-language-1.1.1 googleapis-common-protos-1.5.9 pyasn1-0.4.5 pyasn1-modules-0.2.4 rsa-4.0
$ vi ~/.bashrc
Added this line to the end of my ~/.bashrc (or whatever it is told to you):
export PATH=/home/grad3/jalal/.local/bin:$PATH
$ source ~/.bashrc
I'm trying to install the library requests in pipenv, with Python 3. I've tried:
pip install requests, before forgetting that pip installs only for Python 2, leading to,
pip3 install requests, which returns assuringly
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2.19.1)
Requirement already satisfied: idna<2.8,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests) (2.7)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests) (1.23)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests) (2018.8.24)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from requests) (3.0.4)
When I run my python files with import requests, everything works, but when I run pipenv run python mypythonscript.py, I get the error ModuleNotFoundError: No module named 'requests'. Please advise what I'm missing.
The problem here is that pip3 install requests runs outside of pipenv's virtualenv, it is installed outside of virtualenv, and thus requests library is not found from code running inside the virtualenv.
The correct way to install the library into the virtualenv is pipenv install requests, which will also add requests to your Pipfile. If you want to install it temporarily without saving into the Pipfile, you can run pipenv run pip install requests.
When I run my flask project on my server, I get the following error:
Traceback (most recent call last):
File "File.py", line 1, in <module>
from flask import Flask, request
ImportError: No module named 'flask'
But I have flask installed!
$sudo pip install flask
Requirement already satisfied: flask in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: itsdangerous>=0.21 in /usr/local/lib/python2.7/dist-packages (from flask)
Requirement already satisfied: click>=2.0 in /usr/local/lib/python2.7/dist-packages (from flask)
Requirement already satisfied: Werkzeug>=0.7 in /usr/local/lib/python2.7/dist-packages (from flask)
Requirement already satisfied: Jinja2>=2.4 in /usr/local/lib/python2.7/dist-packages (from flask)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python2.7/dist-packages (from Jinja2>=2.4->flask)
This is driving me crazy. I've tried what other SO answers have suggested, including using a venv, but they all produce this same error. Anyone have a suggestion?
$ which python
/usr/bin/python
$ which python3
/usr/bin/python3
I'm running python 3.5.2
I'm running python 3.5.2
As the text says, Flask is not installed there.
Requirement already satisfied: flask in /usr/local/lib/python2.7/dist-packages
This folder is also the system Python, not the virtualenv, if you are using one. You can set virtualenv to use the system installed packages, but again, that path is not Python3.
The root issue is that using sudo executed pip under a different user account
Either use Python2, or install using pip3 or python3 -m pip and you shouldn't need sudo