pip setup and setting PYTHONPATH - python

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.

Related

No module named 'appium' but I've installed it

I've installed appium on my system and use:
from appium import webdriver
by python3.6.
but in other code when I use it by python3.8 return me:
ModuleNotFoundError: No module named 'appium'
what's the problem with this error?!
The basic crux of the problem is that those 2 python versions are not accessing the same location of installed pip modules. Try using the python -m pip install SomePackage method to call pip of specific Python Binary.
This snippet will help.
python38 -m pip install Appium-Python-Client
Not sure, how you manage those versions of python, but the basic gist of invoking specific pip version works.
Try whereis pip or which pip to ensure the correct pip is being called.

ModuleNotFoundError: No module named 'kmodes'

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

Getting ImportError: No module named 'Crypto' after installation

I am getting ImportError: No module named 'Crypto' error when trying to run. I have installed pycrypto using pip install pycrypto and updated it also. Everything I have tried to far has been unsuccessful.
Tried:
reinstalling pycrypto,
updating both python and pycrypto
Any suggestions?
The error messages says, it does not able to find the module so please try to run below command,
#pip list -- # what does it show to you, if it would have installed successfully it will show you up there.
if "pip install pycrypto" doesn't work so try to download the source tar ball and try to install it from prompt.
pip download pycrypto
it will download tar.gz file.. so you can install using with pip install --no-index --find-links /path/to/some/dir/ pycrypto
for python3.5 version
python3.5 -m pip install pycrypto
this will install in python3.5 environment and after that you can able to import pycrypto module
Is python defined properly on your machine?
Make sure PATH environment variable has python's installation folder in it

python install module apiclient

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.

Import Error: No module named requests

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.

Categories