I can't seem to use sudo pip install correctly so that it installs into the following directory:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
so that I can then import the module using python
I've run
sudo pip install scikit-learn --upgrade
Result
Requirement already up-to-date: scikit-learn in /usr/local/lib/python2.7/site-packages Cleaning up...
However, it's not in the correct directory
How do I get sudo pip install to install into correct directory?
In addition, I've tried
sudo pip install Scrappy
I get the following message
new-host-2:site-packages Chris$ sudo pip install Scrapy Password: Requirement already satisfied (use --upgrade to upgrade): Scrapy in /usr/local/lib/python2.7/site-packages Requirement already satisfied (use --upgrade to upgrade): Twisted>=10.0.0 in /usr/local/lib/python2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.8.0 in /usr/local/lib/python2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): queuelib in /usr/local/lib/python2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): lxml in /usr/local/lib/python2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /usr/local/lib/python2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /usr/local/lib/python2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /usr/local/lib/python2.7/site-packages (from Scrapy) Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /usr/local/lib/python2.7/site-packages (from Twisted>=10.0.0->Scrapy) Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.2.1 in /usr/local/lib/python2.7/site-packages (from pyOpenSSL->Scrapy) Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages (from zope.interface>=3.6.0->Twisted>=10.0.0->Scrapy) Requirement already satisfied (use --upgrade to upgrade): cffi>=0.8 in /usr/local/lib/python2.7/site-packages (from cryptography>=0.2.1->pyOpenSSL->Scrapy) Requirement already satisfied (use --upgrade to upgrade): pycparser in /usr/local/lib/python2.7/site-packages (from cffi>=0.8->cryptography>=0.2.1->pyOpenSSL->Scrapy)
Both these instances demonstrate that it's been installed but not correctly. For example, when I run the following import in python:
import scrapy --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-6-51c73a18167b> in <module>() ----> 1 import scrapy ImportError: No module named scrapy
I've tried the following:
sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
The Python "ModuleNotFoundError: No module named 'pip'" occurs when pip is not installed in our Python environment. To solve the error, install the module by running the python -m ensurepip --upgrade command on Linux or MacOS or py -m ensurepip --upgrade on Windows.
From the comments to the original question, it seems that you have multiple versions of python installed and that pip just goes to the wrong version.
First, to know which version of python you're using, just type which python
. You should either see:
which python /Library/Frameworks/Python.framework/Versions/2.7/bin/python
if you're going to the right version of python, or:
which python /usr/bin/python
If you're going to the 'wrong' version. To make pip go to the right version, you first have to change the path:
export PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin/python:${PATH}
typing 'which python' would now get you to the right result. Next, install pip (if it's not already installed for this installation of python). Finally, use it. you should be fine now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With