I run my python scrapy project shows the error no module named 'requests'
So I type pip install requests
and then terminal information:
Requirement already satisfied: requests in ./Library/Python/2.7/lib/python/site-packages (2.22.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./Library/Python/2.7/lib/python/site-packages (from requests) (3.0.4)
Requirement already satisfied: idna<2.9,>=2.5 in ./Library/Python/2.7/lib/python/site-packages (from requests) (2.8)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./Library/Python/2.7/lib/python/site-packages (from requests) (1.25.7)
Requirement already satisfied: certifi>=2017.4.17 in ./Library/Python/2.7/lib/python/site-packages (from requests) (2019.11.28)
type command pip list can see request 2.22.0
I type command python --version to check the python version:
python 2.7.16
Finally I run my scrapy project again still see the same error no module named 'requests'
I have no idea how to fix the error now, any help would be appreciated. Thanks.
Install python3 and pip3 and then pip3 install requests
if you are on ubuntu python3 is installed by default
you should first install pip3 by apt install python3-pip and then pip3 install requests
If you are using two different versions of Python, it should explain why you can't use your module.
To install the module on Python 3, try:
pip3 install requests
And make sure, you are using the correct version.
Check if you are using the same interpreter to which you have installed the package using pip install. As a best practice to avoid this type of issues when you have multiple versions of python, use pip as a module instead of directly calling pip.
eg:
python -m pip install requests
python3 -m pip install requests
Related
I search on google how to add OpenSSL in python. The command is easy to run.
pip install pyOpenSSL or pip3 install pyOpenSSL. I don't know if my OpenSSL is already installed. I have this response when I installed openssl.
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Requirement already satisfied: pyopenssl in /usr/local/lib/python3.9/site-packages (20.0.1)
Requirement already satisfied: cryptography>=3.2 in /usr/local/lib/python3.9/site-packages (from pyopenssl) (36.0.1)
Requirement already satisfied: six>=1.5.2 in /usr/local/lib/python3.9/site-packages (from pyopenssl) (1.16.0)
Requirement already satisfied: cffi>=1.12 in /usr/local/lib/python3.9/site-packages (from cryptography>=3.2->pyopenssl) (1.15.0)
Requirement already satisfied: pycparser in /usr/local/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=3.2->pyopenssl) (2.21)
DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
this is my index.py code
import base64
import json
import requests
from OpenSSL import crypto
when I run this command python3 index.py. I always get this error
ModuleNotFoundError: No module named 'OpenSSL'
May i know what's the issue in my setup? Im new in python code. My python version is 3.10.0
It looks like you have pyopenssl installed for a Python 3.9 installation (look at the path: /usr/local/lib/python3.9), but you are trying to run with a Python 3.10 installation.
Use the pip from your Python 3.10 installation to install the required packages. python3 -m pip install pyOpenSSL should do that, regardless of what the standalone pip command resolves to.
I am trying to use PyCharm for my python 3 coding on my Linux, and it works great 90% of the time, but I notice that on occasion I cannot import certain packages. For example, when I click Settings->Project->Python Interpreter and try to install 'opencv-python', I get this error:
AttributeError: module 'setuptools.build_meta' has no attribute '__legacy__'
When I try to install opencv-python with pip I get this message:
$ pip install opencv-python
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: opencv-python in ./.local/lib/python3.6/site-packages (4.5.1.48)
Requirement already satisfied: numpy>=1.13.3 in ./.local/lib/python3.6/site-packages (from opencv-python) (1.19.2)
There seems to be some discrepency between the packages my computer has installed and the packages that PyCharm has installed. How can I solve this problem?
Hi there boys and girls,
I am trying to run a script written in python and the console is telling me this:
Install the following library to make this script work
Impacket : https://github.com/CoreSecurity/impacket.git
PyCrypto : https://pypi.python.org/pypi/pycrypto
The problem is that I have already installed those python packages in python3 so when I make a request via pip for those packages I receive this:
Requirement already satisfied: impacket in /usr/local/lib/python3.8/dist-packages (0.9.17)
Requirement already satisfied: ldap3>=2.5.0 in /usr/lib/python3/dist-packages (from impacket) (2.7)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from impacket) (1.15.0)
Hid the rest of the lines but the idea is that. I understand that the package is already installed in my system but I cannot use those with python2.7.
Any idea how to solve this?
In this case the error is because you have not installed impacket for python2.7.
Before installing impacket we need to install pip2 in python2.7, Download get-pip.py form Link
if pip2 is already installed you can verify this by
pip --verison, output of that command should be
pip 20.3.3 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
If pip2 is not installed then install pip2 in python2 package using sudo python2 get-pip.py
Next, install impacket for python2 using pip install . (this must be with in the impacket directory link)
then try to run your script
I want to check PEP-3101 standard for some codes that I have, for this, I want to install flake8-pep3101.
I can not directly install it as it requires PIP upgrade, so I upgrade my PIP from 19.0.3 to 19.1.1.
After upgrade, I began to install it by running
pip install flake8-pep3101
I received this error:
"Collecting flake8-pep3101pip ERROR: Could not find a version that satisfies the requirement flake8-pep3101pip (from versions: none)
ERROR: No matching distribution found for flake8-pep3101pip"
I already have FLAKE8 installed and Phyton 3.7.
What can I do to solve this problem ? it seems that there is no flake8-pep3101 module for this particular python.
I tried to upgrade FLAKE8 using PIP command "pip install --upgrade FLAKE8" and "pip3 install --upgrade FLAKE8":
It gives me error :
Requirement already up-to-date: FLAKE8 in c:\users\mydir\dev\myvirt\lib\site-packages (3.7.7) Requirement already satisfied, skipping upgrade: entrypoints<0.4.0,>=0.3.0 in c:\users\mydir\dev\myvirt\lib\site-packages (from FLAKE8) (0.3) Requirement already satisfied, skipping upgrade: pycodestyle<2.6.0,>=2.5.0 in c:\users\mydir\dev\myvirt\lib\site-packages (from FLAKE8) (2.5.0)
Requirement already satisfied, skipping upgrade: pyflakes<2.2.0,>=2.1.0 in c:\users\mydir\dev\myvirt\lib\site-packages (from FLAKE8) (2.1.1) Requirement already satisfied, skipping upgrade: mccabe<0.7.0,>=0.6.0 in c:\users\mydir\dev\myvirt\lib\site-packages (from FLAKE8) (0.6.1)
From what I can tell, you need to update/reinstall FLAKE8.
To update FLAKE8, use:
pip install --upgrade `FLAKE8`
To install the latest version of FLAKE8, use:
pip install `FLAKE8`
To install a specific version of FLAKE8, use:
pip install FLAKE8==<VERSION>
To install a version of FLAKE8 greater than or equal to one version and less than another, use:
pip install FLAKE8>=<LOW>,<HIGH>
NOTE: if you're using python3 use pip3 instead of pip.
Good luck.
When I run:
sudo -H pip install finsymbols
I get the below response:
Requirement already satisfied: finsymbols in /usr/local/lib/python2.7/dist-packages
Requirement already satisfied: beautifulsoup4>=4.2.1 in /usr/local/lib/python2.7/dist-packages (from finsymbols)
then when I run
$ python
>>> from finsymbols import symbols
I get
File "", line 1, in
ImportError: No module named finsymbols
My question is, why am I getting the error when the module is installed?
You may have multiple versions of Python.
Requirement already satisfied: finsymbols in /usr/local/lib/python2.7/dist-packages Requirement already satisfied: beautifulsoup4>=4.2.1 in /usr/local/lib/python2.7/dist-packages (from finsymbols)
Pip has installed it in python2.7 path. Your default Python may be different.
So try using
$ python2.7
instead of
$ python
If you want to install a module that runs on Python 3.x, you need to use
pip3 install module_name
Or link the pip3 executable in /usr/bin to replace pip. In this way, you can use pip to install Python 3.x modules.
Here I strongly recommend to use virtualenv to manage your Python module environments. More details can be found here.
Thanks jonatan, that worked.
I ran
pip install finsymbols
not
sudo -H pip install finsymbols
and that fixed the issue