SyntaxError when pip install pip ( def read(rel_path: str)) - pip

when using pip I get the following warning:
$ pip install pip
Requirement already satisfied (use --upgrade to upgrade): pip in /usr/lib/python2.7/site-packages
You are using pip version 8.1.2, however version 22.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
So I follow the suggestion, but I get a SyntaxError:
$ pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/99/bb/696e256f4f445809f25efd4e4ce42ff99664dc089cafa1e097d5fec7fc33/pip-22.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-k03IN1/pip/setup.py", line 7
def read(rel_path: str) -> str:
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-k03IN1/pip/
You are using pip version 8.1.2, however version 22.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
My default pip is not the one I want to be:
$ ~/anaconda3/bin/pip --version
pip 22.1 from /home/mdi0316/.local/lib/python3.8/site-packages/pip (python 3.8)
$ ~/anaconda3/bin/pip3 --version
pip 22.1 from /home/mdi0316/.local/lib/python3.8/site-packages/pip (python 3.8)
$ which pip
/usr/bin/pip
$ pip --version
pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)
$ echo $PATH
/home/mdi0316/bin:/home/mdi0316/anaconda3/envs/nagare_env/bin:/home/mdi0316/anaconda3/condabin:/home/mdi0316/anaconda3/envs/nagare_env/bin:/cm/shared/apps/TURBOMOLE/bin/em64t-unknown-linux-gnu_smp:/cm/shared/apps/TURBOMOLE/scripts:/cm/local/apps/cuda/libs/current/bin:/cm/shared/apps/cuda11.1/sdk/11.1.1/bin/x86_64/linux/release:/cm/shared/apps/cuda11.1/toolkit/11.1.1/bin:/cm/shared/apps/python3.8.7/bin:/cm/shared/apps/openmpi/gcc/64/4.0.5/bin:/cm/local/apps/gcc/8.2.0/bin:/cm/shared/apps/slurm/18.08.9/sbin:/cm/shared/apps/slurm/18.08.9/bin:/cm/local/apps/environment-modules/4.2.1/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/ibutils/bin:/sbin:/usr/sbin:/cm/local/apps/environment-modules/4.2.1/bin
I am within a personally created anaconda environment (nagare_env).
Yet, the default pip in in ~/usr
I also tried to install pip through pip3, but I could solve this neither way.
$ pip3 install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./.local/lib/python3.8/site-packages (22.1)
$ pip3 install --upgrade --trusted-host pypi.org --trusted-host files.pythonhosted.org pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./.local/lib/python3.8/site-packages (22.1)
any hint?
Thanks
Marco

I faced the same issue on my centos. Guess my pip file was corrupted. I installed it again and was working fine.
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py
pip install --upgrade setuptools

"pip 21.0, in January 2021, removed Python 2 support, per pip’s Python 2 support policy.
you should change your pip version
from: https://pypi.org/project/pip/

Related

Why I can't pip install nltk on mac os?

I'm using mac os mojave, install python 2.7 and install pip using python get-pip.py, I already try those command to install pip :
pip install --upgrade pip
pip install nltk
and try
sudo python -m pip install --upgrade nltk
But also result to same error like in this image
Or here in text:
error in nltk setup command: 'install_requires' must be a string or
list of strings containing valid project/version requirement
specifiers; Expected version spec in singledispatch; python_version <
"3.4" at ; python_version < "3.4"
Is it because my python version (2.7) ? But in pip ntlk page it says also support 2.7
update:
pip install nltk success after running :
pip install --upgrade setuptools pip --user
Start with upgrading installation tools:
pip install --upgrade setuptools pip

How do you upgrade version of pip on Repl.it?

I'm having issues upgrading pip using the pip3 install --upgrade pip3 command on Repl.it and getting this error:
Repl.it: Installing fresh packages
Usage: pip3 [options]
pip3: error: no such option: --upgrade
You are using pip version 9.0.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Repl.it: package installation failed!
How can I upgrade pip on Repl.it?

Pytorch installation issue under Anaconda

I followed the link here to install fastai library using pip install git+https://github.com/fastai/fastai.git
It gave me the following error message. These messages keep the same even I installed Pytorch successfully using conda install pytorch-cpu -c pytorch
and pip3 install torchvision. What can be the reason?
Collecting torch<0.4 (from fastai==0.7.0)
Using cached https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\shuxi\AppData\Local\Temp\pip-install-7sjptuad\torch\setup.py", line 11, in <module>
raise RuntimeError(README)
RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).
Please follow the instructions at http://pytorch.org/ to install with miniconda instead.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\shuxi\AppData\Local\Temp\pip-install-7sjptuad\torch\
To fix this, do:
$ pip install --upgrade git+https://github.com/fastai/fastai.git
OR
$ pip install --no-cache-dir git+https://github.com/fastai/fastai.git
Your command probably failed because you have installed a old version of torch (0.1.2) some time ago. pip was not supported for torch install for that version and pip instead redirected the user to open pytorch.org in the browser. In your case, pip is reusing this cached package. --upgrade forces pip to choose latest version of all depending packages.

brew or pip - install credstash - errors - No named formulae found in taps / OSErr six-1.4.1-py2.7.egg-info operation not permitted

Getting the following error on my Mac Terminal window.
$ pip --version
pip 6.1.1 from /Library/Python/2.7/site-packages (python 2.7)
Python version is 2.7.10
While trying to install credstash using brew, I'm getting the following error.
$ `which python` --version && brew update && brew install credstash
Python 2.7.10
Already up-to-date.
Error: No available formula with the name "credstash"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.
Got the similar error, when I tried to install pip3 using brew.
Tried installing credstash from pip but that errored out as well.
[arun#MacBook-Pro-2 ~/aks/wspace] $ pip install credstash
You are using pip version 6.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting credstash
Using cached credstash-1.12.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): pycrypto>=2.6.1 in /Library/Python/2.7/site-packages (from credstash)
Collecting boto3>=1.1.1 (from credstash)
Using cached boto3-1.4.2-py2.py3-none-any.whl
Requirement already satisfied (use --upgrade to upgrade): jmespath<1.0.0,>=0.7.1 in /Library/Python/2.7/site-packages (from boto3>=1.1.1->credstash)
Collecting botocore<1.5.0,>=1.4.1 (from boto3>=1.1.1->credstash)
Using cached botocore-1.4.87-py2.py3-none-any.whl
Collecting s3transfer<0.2.0,>=0.1.0 (from boto3>=1.1.1->credstash)
Using cached s3transfer-0.1.10-py2.py3-none-any.whl
Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.5.0,>=1.4.1->boto3>=1.1.1->credstash)
Using cached python_dateutil-2.6.0-py2.py3-none-any.whl
Collecting docutils>=0.10 (from botocore<1.5.0,>=1.4.1->boto3>=1.1.1->credstash)
Using cached docutils-0.13.1-py2-none-any.whl
Collecting futures<4.0.0,>=2.2.0 (from s3transfer<0.2.0,>=0.1.0->boto3>=1.1.1->credstash)
Using cached futures-3.0.5-py2-none-any.whl
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore<1.5.0,>=1.4.1->boto3>=1.1.1->credstash)
Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six, python-dateutil, docutils, botocore, futures, s3transfer, boto3, credstash
Found existing installation: six 1.4.1
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 246, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 352, in run
root=options.root_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 687, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 730, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 126, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 292, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/z5/37m4q63j3bn48y3dxgf40tdm0000gn/T/pip-LMRqSS-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
IF I don't use sudo in the above command, then I get the following exception error:
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/concurrent'
To get latest pip, as pip is provided via python on macOS, if I try to install python using brew, I'm getting the following, poking into it how I can remove Xcode first:
$ brew install python
Error: Your Xcode (5.0.2) is too outdated.
Please update to Xcode 8.2 (or delete it).
Xcode can be updated from the App Store.
$ pip --version
pip 6.1.1 from /Library/Python/2.7/site-packages (python 2.7)
As I thought I have an older pip version, I download this file:
$ wget https://bootstrap.pypa.io/get-pip.py && sudo python get-pip.py
Which successfully installed a newer version of pip. Now showing:
$ pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages (python 2.7)
Retried doing pip install credstash but still getting the same error (with or without sudo).
I tried the following to get credstash installed.
Downloaded Python3 Mac binary from here.
https://www.python.org/ftp/python/3.5.2/python-3.5.2-macosx10.6.pkg
Installed the .pkg file GUI way.
Opened a Terminal window in Mac.
[arun#MacBook-Pro-2 /tmp] $ which pip
/usr/local/bin/pip
[arun#MacBook-Pro-2 /tmp] $ pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages (python 2.7)
[arun#MacBook-Pro-2 /tmp] $ which python
/usr/bin/python
[arun#MacBook-Pro-2 /tmp] $ python --version
Python 2.7.10
[arun#MacBook-Pro-2 /tmp] $ which python3
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
[arun#MacBook-Pro-2 /tmp] $ python3 --version
Python 3.5.2
[arun#MacBook-Pro-2 /tmp] $ which pip3
/Library/Frameworks/Python.framework/Versions/3.5/bin/pip3
[arun#MacBook-Pro-2 /tmp] $ pip3 --version
pip 8.1.1 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5)
[arun#MacBook-Pro-2 /tmp] $
[arun#MacBook-Pro-2 /tmp] $ pip3 install credstash
Collecting credstash
Using cached credstash-1.12.0.tar.gz
Collecting pycrypto>=2.6.1 (from credstash)
Using cached pycrypto-2.6.1.tar.gz
Collecting boto3>=1.1.1 (from credstash)
Using cached boto3-1.4.2-py2.py3-none-any.whl
Collecting s3transfer<0.2.0,>=0.1.0 (from boto3>=1.1.1->credstash)
Using cached s3transfer-0.1.10-py2.py3-none-any.whl
Collecting botocore<1.5.0,>=1.4.1 (from boto3>=1.1.1->credstash)
Using cached botocore-1.4.87-py2.py3-none-any.whl
Collecting jmespath<1.0.0,>=0.7.1 (from boto3>=1.1.1->credstash)
Using cached jmespath-0.9.0-py2.py3-none-any.whl
Collecting docutils>=0.10 (from botocore<1.5.0,>=1.4.1->boto3>=1.1.1->credstash)
Downloading docutils-0.13.1-py3-none-any.whl (536kB)
100% |████████████████████████████████| 542kB 1.3MB/s
Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.5.0,>=1.4.1->boto3>=1.1.1->credstash)
Using cached python_dateutil-2.6.0-py2.py3-none-any.whl
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore<1.5.0,>=1.4.1->boto3>=1.1.1->credstash)
Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: pycrypto, docutils, six, python-dateutil, jmespath, botocore, s3transfer, boto3, credstash
Running setup.py install for pycrypto ... done
Running setup.py install for credstash ... done
Successfully installed boto3-1.4.2 botocore-1.4.87 credstash-1.12.0 docutils-0.13.1 jmespath-0.9.0 pycrypto-2.6.1 python-dateutil-2.6.0 s3transfer-0.1.10 six-1.10.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[arun#MacBook-Pro-2 /tmp] $
[arun#MacBook-Pro-2 /tmp] $ which credstash
/Library/Frameworks/Python.framework/Versions/3.5/bin/credstash
[arun#MacBook-Pro-2 /tmp] $
If you're trying to install to system Python then you need sudo. If you want to just play around, look into creating a virtualenv and install there. http://docs.python-guide.org/en/latest/dev/virtualenvs/

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

Resources