Cannot install pip for python3 on mac - macos

When I run
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python3 get-pip.py
It gives me this error:
Downloading/unpacking pip
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pip
Cleaning up...
No distributions at all found for pip
Storing debug log for failure in /var/root/.pip/pip.log
However if I just run:
sudo python get-pip.py
There is no problem:
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-1.5.2-py2.py3-none-any.whl#md5=445a893564065937c0f31ac2cc8e2f35
Downloading pip-1.5.2-py2.py3-none-any.whl (1.2MB): 1.2MB downloaded
Installing collected packages: pip
Found existing installation: pip 1.5.1
Uninstalling pip:
Successfully uninstalled pip
Successfully installed pip
Cleaning up...
Can anyone help please? Thanks!

This is a simple permissions issue. If you're installing to the system Python installation, you should need root, which is what sudo provides.
If you need to install stuff where you don't have root privileges, you need to look into Python virtual environments.

Related

How would you install python modules/packages so that my script can be run with pypy3 instead of Python3? ImportError: No module named

I have Python3.8 built from source on my Debian 10 Xfce desktop (binaries are not available in Debian repositories). That said, whenever I can, I run my python scripts with pypy3, which I do for the sake of performance.
Now, when I run the following code with pypy3 :
#!/usr/bin/env python3.8
import requests
from bs4 import BeautifulSoup
url = input("What is the address of the web page in question?")
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
print(soup.title.string)
I get from pypy3:
ImportError: No module named 'requests'
The same script is run by Python3.8 without any problems
I assume that I would have to install the module in a similar way that I did it for Python, that is: sudo pip3.8 install requests.
Based on my research of a similar problem described on Stackoveflow I tried:
pypy3 -m pip3.8 install requests
and got the following from my pypy3:
Error while finding module specification for 'pip3.8' (ImportError: No >module named 'pip3')
Then I also tried to run:
pypy3 -m pip install requests
And got the following:
No module named pip
My pip3.8 works fine for Python3.8, not for my pypy3, though.
How should I look for modules in pypy3. And how should I install them?
Is the problem with installing and importing modules one of the reasons reason for the low usage of pypy3?
Run this once to install pip itself: pypy3 -m ensurepip
The next version of PyPy will improve the error message to describe this command explicitly when you do pypy3 -m pip and pip is not installed yet.
pypy3
Enable snaps on Debian and install pypy3
Snaps are applications packaged with all their dependencies to run on all popular Linux distributions from a single build. They update automatically and roll back gracefully.
Snaps are discoverable and installable from the Snap Store, an app store with an audience of millions.
Enable snapd:
sudo apt update
sudo apt install snapd
Install pypy3:
sudo snap install pypy3 --classic
Normally, the pip and package are installed as follows
First of all, you need to install the pip
Install pip for Python 3
Follow the steps below to install Pip for Python 3 on Debian:
First, update the package list with:
sudo apt update
Next, install pip for Python 3 and all of its dependencies by typing:
sudo apt install python3-pip
Verify the installation by printing the pip version:
pip3 --version
The version number may be different, but it will look something like the one below:
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
Pip Usage
With pip, we can install packages from PyPI, version control, local projects, and from distribution files but in most cases, you will install packages from PyPI.
we want to install a package named croniter, we can do that by issuing the following command:
pip install requests
To uninstall a package run:
pip uninstall requests

How can I install torch and torchvision with pip and python 3.8.3 on windows in an virtual environment?

I created a virtual environment for my project and I'm trying to install torch via pip.
pip install torch===1.5.1 torchvision===0.6.1 -f https://download.pytorch.org/whl/torch_stable.html
This gives me the error -
ERROR: Could not find a version that satisfies the requirement torch===1.5.1 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch===1.5.1
Some solutions recommend the use of conda, is it necessary? Can I not do it through just pip
You can try to install directly from the wheels files:
pip install https://download.pytorch.org/whl/cu102/torch-1.5.1-cp36-cp36m-win_amd64.whl
pip install https://download.pytorch.org/whl/cu102/torchvision-0.6.1-cp36-cp36m-win_amd64.whl

Installing pip in virtualenv using easy_install, for TensorFlow

I'm starting to experiment with TensorFlow and am following the TensorFlow guide to installing on Mac OS X, using virtualenv as recommended.
The instructions essentially boil down to the following:
sudo easy_install pip
sudo pip install --upgrade virtualenv
virtualenv --system-site-packages <mydirectory>
source ./<mydirectory>/bin/activate
easy_install -U pip
pip install --upgrade tensorflow
When I get to the easy_install -U pip step, I get the error:
"<mydirectory>/bin/easy_install: <mydirectory>/bin/python: bad interpreter: permission denied".
I can't understand what's going on here. My (usual) user has full permissions to <mydirectory>, where I believe everything should be running.
I assume running an older version of pip is not big deal, but something obviously goes wrong when I try the pip install --upgrade tensor flow step, because when I try running a Python script that uses TensorFlow I get the exception "import tensor flow as tf. Import error: no module named tensorflow".
Some help would be much appreciated please :)

Getting "ImportError: No Module named yaml" error

Computer: MacBook Pro mid 2012, running El Capitan 10.11.4
Python version 2.7.10
I've been trying to install ansible from source, and I've run these two commands (following the steps on ansibles documentation):
git clone git://github.com/ansible/ansible.git --recursive
cd ./ansible
and then ran this
source ./hacking/env-setup
I've also already installed these packages
sudo pip install paramiko PyYAML Jinja2 httplib2 six
However, if I try and run ansible by typing it in the terminal, I get the following error.
Traceback (most recent call last):
File "/Users/[myusr]/rock/ansible/bin/ansible", line 81, in <module>
from ansible.cli.adhoc import AdHocCLI as mycli
File "/Users/[myusr]/rock/ansible/lib/ansible/cli/__init__.py", line 27, in <module>
import yaml
ImportError: No module named yaml
What should be done here?
Do you have yaml module installed? If not, try installing yaml using the following command:
sudo pip install pyyaml
Had the same issue. Got past it using #FranMowinckel's answer.
First I typed:
pip --version
it outputted python 3. But, when I tried:
sudo python -m pip install pyyaml
I got an error saying:
Error: No module named pip
So, finally running:
sudo easy_install pip
everything worked fine.
Go back and run:
sudo python -m pip install pyyaml
(you may have to run this with all the other modules as well)
Now you should finally be able to run your initial command which failed.
For python 3.6 you can install it with
pip3 install pyyaml
if there is a problem in importing, do
pip3 uninstall pyyaml
and then install it again:
pip3 install pyyaml
#bigdata2's answer is correct but it might also happen that there's a conflict with python 3. So, check pip version (pip --version) and if it outputs python 3 then:
sudo python -m pip install pyyaml
So it gets installed for the same version as python.
I had this problem because I installed it with
sudo pip install pyyaml --upgrade
instead of
sudo -H pip install pyyaml --upgrade
Uninstalling and re-installing pyyaml fixed the problem for me.
This should work:
sudo pip install pyyaml
Try this
pip install ruamel.yaml

Pip install fontforge, says Couldnot find a version

I have done, apt-get install fontforge on my ubuntu system. When i do import fontforge in my python code, it throws error as, No module named fontforge.
When i do, pip install fontforge, it throws error as,,
Could not find a version that satisfies the requirement fontforge (from versions: )
No matching distribution found for fontforge
How can i install fontforge's python libs?
You may want to install python3-fontforge.
sudo apt-get install python3-fontforge
After that you should be able to use fontforge in ubuntu's python version 3.
You can verify by doing /usr/bin/python3 -c "import fontforge;print(fontforge)". This should now print the path to the fontforge python module.
Try installing a specific version
pip install fontforge==1.0
For me , the above command completes without errors. If any errors, upgrade pip using
pip install --upgrade pip
And try again. You may try allow externally hosted files also.
pip install --allow-all-external fontforge

Resources