I know there are many posts on this, and I've tried using the solutions provided, but to no avail. I tried pip install requests and pip install requests --upgrade:
pip install requests --upgrade
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Requirement already up-to-date: requests in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
I then tried running pip install --upgrade pip, yet when I run my file I still get
Import Error: No module named requests
I am able to use requests in PyCharm, so I don't know what's causing this. Can someone please help?
You installed requests into a different Python installation. The /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages is the site-packages directory for the Mac OS X /usr/bin/python installation.
PyCharm is not currently configured to use that Python installation; check what Python is being used either by looking at your PyCharm settings, or by asking Python directly with:
import sys
print(sys.executable)
Note that PyCharm can handle package installations for you as well; rather than use the command line pip consider using PyCharm, as it'll use the currently configured Python installation in that case.
install package name "request" from pychram package setting. then it will be work fine.
If you are having this issue in Pycharm and you have configured your Pycharm to create projects in virtual environments, then you can use the Terminal in Pycharm to run the
pip3 install requests
to resolve this issue. This is by design to ensure you control dependencies.
Related
I have tried installing it using pip install kmodes and it says that "Requirement is satisfied" but am not being able to import the library even after that.
The list of libraries doesn't have kmodes even after installing. Attaching screenshot for reference. What is happening here?
from kmodes.kprototypes import KPrototypes
ModuleNotFoundError: No module named 'kmodes'
Maybe your PIP is installing to the wrong version of python and the code you are running is being interreted by a later version
Try copying your python executable path and running this
C:\Users\username\AppData\Local\Programs\Python\Python39\python.exe -m pip install kmodes
Another reason is that kmodes did not install properly the first time
Try running this as an administrator
pip uninstall kmodes && pip install kmodes
I'm trying to install a package onto Pycharm using PIP. I am running Anacondas on a Pycharm IDE. I know that you use the project interpreter to install packages and I also know that the package should be located under PyPi but when I go to the project interpreter and click add package the package I'm trying to install doesn't appear under the list of available packages.
I know that you can install the package using PIP and I have PIP installed through Anaconda although I am unsure how to run a pip command through Pycharm. I've tried typing it into the cmd console and the python code and neither seems to have any effect...
The package I'm trying to install is: https://github.com/seatgeek/fuzzywuzzy.
The pip command to install it is: pip install fuzzywuzzy but I am unsure as to where I'm supposed to run that command.
I'm fairly new at Python so any help would be much appreciated!
Thank you!
I found someone else's answer that works for me:
You need to use
import pip
pip.main(['install','packagename'])
Which allows you to manually install packages through pip using Python code.
This is guide for installing the pip packages from Python Console in Pycharm IDE.
Do not forget to run Pycharm as administrator if you are using windows OS before installing the packages.
First of all import the pacakage of pip in python console.
import pip
Installation of Package.
pip.main(['install', '<package_name>'])
Examples
The below command will upgrade the version of package setuptools.
pip.main(['install','--upgrade','setuptools'])
The below command will install the scikit-learn and numpy packages.
pip.main(['install','numpy','scikit-learn'])
The below command will uninstall the scikit-learn package.
pip.main(['uninstall','scikit-learn'])
I was with the same problem, all i did was : Configure the project interpreter to the Python3 inside the venv you are using the pip install.
Remember to activate the venv.
That's it , now you can use the pip install on pycharm or on prompot.
The problem is that even with the "venv/lib/sitepackeges" in the your project's sys.path the pycharm looks only for the packages where the project interpreter is.
I'm trying to test if requests module has been well installed. But I'm getting the following error :
raceback (most recent call last):
File "/Users/macbookpro/Desktop/test.py", line 1, in <module>
import requests
ImportError: No module named requests
when trying to run the following test script:
import requests
print 'test'
But I have installed requests with pip, and pip list command gives the following result :
MBPdeMacBook2:~ macbookpro$ pip list
arrow (0.7.0)
beautifulsoup4 (4.4.1)
classifier (1.6.5)
coursera-dl (0.6.1)
Django (1.8.6)
html5lib (1.0b8)
keyring (9.0)
lxml (3.6.0)
Pillow (3.4.2)
pip (8.0.2)
pyasn1 (0.1.9)
requests (2.14.2)
setuptools (19.4)
six (1.10.0)
urllib3 (1.16)
vboxapi (1.0)
virtualenv (13.1.2)
wheel (0.26.0)
Why requests isn't being imported ?
EDIT :
MBPdeMacBook2:~ macbookpro$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
MBPdeMacBook2:~ macbookpro$ which pip
/usr/local/bin/pip
MBPdeMacBook2:~ macbookpro$ python --version
Python 2.7.11
MBPdeMacBook2:~ macbookpro$ pip --version
pip 8.0.2 from /usr/local/lib/python2.7/site-packages (python 2.7)
In general, you should get into the habit of working in a virtualenv. I find the documentation here to be helpful.
If you install all of your dependencies within the virtual environment, you'll be (mostly) sure that you are installing those deps. in the same environment that you're running the jobs in.
For your case, on the command line go to the directory where your code lives and run
pip install virtualenv
virtualenv my_project
source my_project/bin/activate
Now that the virtualenv is active you can
pip install requests
Only what is installed in the virtualenv will be available. This will keep your system clean. Each project should get its own virtualenv, meaning only the dependencies needed for each project will be available to them. This way you could, say, have version 1 of some dependency installed for one project and version 2 for another. They won't come into conflict.
After you have installed all the dependencies, run
pip freeze > requirements.txt
To get a list of all the dependencies for the project saved. Next time you need to install these, you simply run
pip install -r requirements.txt
Once you are done working in the virtualenv, run
deactivate
I am not 100% sure, but the paths from which python and which pip may indicate that you have two versions installed. The Python version being the old one that was shipped with OS X, and another version.
I would advice you to install Python27 (or even better Python3) from brew.
You can install brew with a single command, and another one for installing Python27/3. When this is done you set the PATH variable in your shell rc file and you should be good to go.
I have Python27 installed (via brew) and my (working environment) reports the following paths:
which python: /usr/local/bin/python
which pip: /usr/local/bin/pip
And
python --version: 2.7.15
pip --version: pip 9.0.1 from /usr/local/lib/python2.7/site-packages (python2.7)
I experienced this same issue on Ubuntu 18.04 LTS, to check that, I first checked if requests library was installed on my system or not.
Run these commands on your terminal inside the virtual environment in which you working
$ python
Then the python command line opens, then run
>>> import requests
After this if you get an ImportError saying, No module named requests, then it means the dependency has not been installed properly. If there is no such error, then it means the dependency is installed successfully.
This can occur for example if pip is actually pip3 and python is actually python2.7.
In your case the which pip and which python eliminate this possibility but it just happened to me.
The solution was to do pip2 instead of pip; if the situation was reversed you can use pip3.
Simply go inside your virtual environment and run below commands:
1). pip install --user pipenv
2). pipenv install requests
after executing the above commands cd to your app folder inside the virtual environment and just run it. Hopefully now it will run.
Reference link: https://python-guide-pt-br.readthedocs.io/pt_BR/latest/dev/virtualenvs.html#make-sure-you-ve-got-python-pip
New to python, and trying to install a module "apiclient"
since my ide pycharm does not recognize that import:
from apiclient.discovery import build
what I tried:
pip install apiclient
download manually the package from
https://developers.google.com/api-client-library/python/start/installation#system-requirements
then I extracted it into
/Users/nirregev/anaconda/bin/google-api-python-client-1.5.0
and ran this on my mac terminal
python setup.py install
but still pycharm does not recognize this module.
According to pycharm I have the following interpreters installed:
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
/Users/nirregev/anaconda/bin/python
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
Try this:
sudo pip install --upgrade google-api-python-client
OR
Make sure you only have google-api-python-client installed. If you have apiclient installed, it will cause a collision. So, run the following:
pip install --force-reinstall google-api-python-client
Answer Source
I ran into this problem and had a tough time figuring it out. In the end, this worked for me:
pip install google-api-python-client==1.5.3
Before doing this, I had version 1.6.2 installed. What I think is going on is that later versions of google-api-python-client dropped the apiclient in favor of the googleapiclient alias; which is an issue because some packages (e.g. airflow) still use that apiclient.discovery import.
Hope this helps.
If you have python3 installed somewhere and you are to install apiclient, it may be installing it in your python3 directory. I had the same problem and when I uninstalled python3 my program ran smoothly.
If you have got both python 2 and python 3 and you're trying to use python 2 for this purpose try the following: sudo pip2 install google-api-python-client==1.5.3 . This worked for me.
I am on Mac, using brew's python, and this worked for me:
1 - As suggested by others, install the API client using pip:
sudo pip install --upgrade google-api-python-client
2 - Make sure you are calling the library in your code as googleapiclient, and not as apiclient, which is deprecated.
3 - Tell Python to look for packages in the pip folder:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages
To make it permanent, add the above line to either your .profile or .bash_profile file in your $HOME.
I'm not experienced in Python, and I need the requests module.
I've tried installing it using pip install requests
The installation went successfully, but when I try to import the module, I get an error like "no module named requests".
Should I add the install location to PYTHONPATH? If yes, how can I find the location where pip installed the files? I don't know about virtualenv, and I am using Ubuntu.
You should install pip for python3 first
How to install pip with Python 3?
then with the pip-3.X install the required module.