Wrong pip3 python location - python

I'm in Ubuntu / Linux
I try to install python3.8.2 with the latest version.
before i install i had Version 3.5.2, and that works very well.
but now pip and pip3 is the same linked location:
pip -V
pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
pip3 -V
pip 20.0.2 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
the problem is why i can't install any packages with the new version error message says:
**
sudo pip3 install nltk
**
WARNING: The directory '/home/fredy/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting nltk
Downloading nltk-3.4.5.zip (1.5 MB)
|████████████████████████████████| 1.5 MB 2.3 MB/s
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-d0mx8gb1/nltk/setup.py'"'"'; __file__='"'"'/tmp/pip-install-d0mx8gb1/nltk/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-d0mx8gb1/nltk/pip-egg-info
cwd: /tmp/pip-install-d0mx8gb1/nltk/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/fredy/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 19, in <module>
from setuptools.dist import Distribution
File "/home/fredy/.local/lib/python3.8/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/home/fredy/.local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
(pip list)
Package Version
---------- -------
pip 20.0.2
setuptools 46.1.1
(pip3 list)
Package Version
---------- -------
pip 20.0.2
setuptools 46.1.1
step1:
how can i come back to python3 with pip3. ?
step2:
how can i fix the error so i can work with 3.8.2 ?
What will you do ? :)
Thanks for your time !

Related

How to install a package from git into a specific directory using pip -t

I have downloaded all of my requirements in AWS Linux + EFS using
pip3 install -t /mnt/efs/fs1/ml/ -r /mnt/efs/fs1/ml/requirements.txt
They get downloaded without an issue and I'm able to call them too. Now I want to install detectron2 but it has to be done separately as it requires torch already in the system.
I install it with:
pip3 install -t /mnt/efs/fs1/ml/ 'git+https://github.com/facebookresearch/detectron2.git'
Even if I have installed torch in above requirements, and able to import it too. I also installed it in the global path too (without -t) but still I'm getting the error:
pip3 install 'git+https://github.com/facebookresearch/detectron2.git'
Defaulting to user installation because normal site-packages is not writeable
Collecting git+https://github.com/facebookresearch/detectron2.git
Cloning https://github.com/facebookresearch/detectron2.git to /tmp/pip-req-build-bcthhh9q
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-bcthhh9q/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-bcthhh9q/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-nmaxo6d1
cwd: /tmp/pip-req-build-bcthhh9q/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-req-build-bcthhh9q/setup.py", line 10, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
What is the problem here? The below command runs perfectly in my system when I don't install requirements.txt with -t flag.
This looks like version issue, version supported for torch and detectron2 should be in sync.You can go through this for details :
https://detectron2.readthedocs.io/en/latest/tutorials/install.html
Found the solution. The PYTHONPATH was pointing to default directory so had to tell the env about the new location of packages.
All you have to do is to run the command in terminal:
export PYTHONPATH="${PYTHONPATH}:/mnt/efs/fs1/ml"
And then use the command as usual. It'll work fine

yfinance - ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output

I am trying to install yfinance "sudo -H pip install yfinance" and keep getting the following error at the bottom of this post. I have uninstalled/installed pip. I have uninstalled/installed setuptools via pip and have tried the following commands:
python3 -m ensurepip --upgrade
Requirement already up-to-date: setuptools in /usr/local/lib/python3.8/site-packages (49.2.0)
Requirement already up-to-date: pip in /usr/local/lib/python3.8/site-packages (20.1.1)
pip install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python3.8/site-packages (20.1.1)
pip install --upgrade setuptools
Requirement already up-to-date: setuptools in /usr/local/lib/python3.8/site-packages (49.2.0)
Python Version
python --version
Python 3.8.3
Pip Version
pip --version
pip 20.1.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)
System Update Checks
sudo apt-get upgrade
sudo apt-get update
Actual error code below when I run "sudo -H pip install yfinance"
*****#*******:~/Desktop/Project$ sudo -H pip install yfinance
Collecting yfinance
Using cached yfinance-0.1.54.tar.gz (19 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xpuca0pe/yfinance/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xpuca0pe/yfinance/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1j4zanh6
cwd: /tmp/pip-install-xpuca0pe/yfinance/
Complete output (11 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 23, in <module>
from setuptools.dist import Distribution
File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 34, in <module>
from setuptools import windows_support
File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
import ctypes
File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
How do I fix this error?
After running this command it fixed the error.
Reference: https://packaging.python.org/tutorials/installing-packages/
sudo -H python -m pip install --upgrade pip setuptools wheel

cloudant module will not install with pip

trying to install the cloudant module on a raspberry pi ver 1 rev b using the instructions from IBM's web page.
first: git clone https://github.com/IBM-Cloud/get-started-python
then: cd get-started-python
finally: pip install -r requirements.txt
I want to use the cloudant module with python 2.7 I've read about the environment variable possibly being an issue, but honestly i'm lost. I've read many posts about problems installing, but so far nothing works...
I get the following error message:
pi#rpi-2:~/hms/get-started-python $ pip install -r requirements.txt
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: Flask>=1.0.0 in /usr/lib/python2.7/dist-packages (from -r requirements.txt (line 1)) (1.0.2)
Collecting cloudant==2.13.0
Using cached cloudant-2.13.0.tar.gz (60 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-d8SSO0/cloudant/setup.py'"'"'; __file__='"'"'/tmp/pip-install-d8SSO0/cloudant/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-7Btkkf
cwd: /tmp/pip-install-d8SSO0/cloudant/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-d8SSO0/cloudant/setup.py", line 33, in <module>
with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
UPDATE:
so this is my code:
from cloudant.client import cloudant
running my code using python3 code.py I get the error message"
Traceback (most recent call last):
File "code.py", line 1, in <module>
from cloudant.client import cloudant
ModuleNotFoundError: No module named 'cloudant'
While I don't fully understand why changing my import statement to from cloudant import Cloundant fixes the issue...
Parameter encoding was added to open() in Python 3.0. This code in setup.py is Python3-only despite the packages declares compatibility with Python2. Please note they provide wheels only for Python3.
Either using encoding is a bug or declaring compatibility with Python2 is a bug. Which one is for the authors to decide. Report the problem and let's them to resolve.
Or try Python3.

error command errored out with exit status 1 pip install [duplicate]

This question already has answers here:
pip3 install mysql-python failed with error code 1 in /tmp/pip-install-4nev4id4/mysql-python/
(2 answers)
Closed 2 years ago.
I use python vitrualenv and when I want to install any packages by pip install <package name> I take that error:
ERROR: Command errored out with exit status 1:
command: /home/user/project/some_project_name/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-sifdsjjx/MySQL-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-sifdsjjx/MySQL-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-sifdsjjx/MySQL-python/pip-egg-info
cwd: /tmp/pip-install-sifdsjjx/MySQL-python/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-sifdsjjx/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-install-sifdsjjx/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I use python 3.7.0
pip 20.0.2
Try to upgrade setuptools:
pip install --upgrade setuptools
UPDATE
As mentioned in the comments, you are attempting to install MySQL-python which is a very old package (last release was made back in 2014).
You can however install a more recent one, called MySQLdb which is a thin python wrapper around C module which implements API for MySQL database:
pip install mysqlclient
Did you install the SQL client dev pacakge on your system?
sudo apt install libmysqlclient-dev
if you are using mariadb, the drop in replacement for mysql, then run
sudo apt install libmariadbclient-dev
then try again

pip3 install mysql-python is failing on Mac

There are a lot of similar question but all of them has different solution. And none of them work for me.
I'm trying to install Mysql connector for Django project but it gives below error.
First I have installed latest version of Django.
Then install mysql with below code
brew install mysql - Worked fine.
Then this is the code which I'm trying install connector.
pip3 mysql-python. Was using easy_install mysql-python before but both of them are not working.
Python Version: 3.8.0
Django Version: 2.2.7
MySql Version: 8.0.18
pip3 mysql-python gives this error:
Collecting mysql-python
Using cached https://files.pythonhosted.org/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py'"'"'; __file__='"'"'/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/pip-egg-info
cwd: /private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/
Complete output (7 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/private/var/folders/6n/d2t3k0sd4l1d78bgk_ll5psm0000gn/T/pip-install-4nmg9waj/mysql-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ModuleNotFoundError: No module named 'ConfigParser'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
You're installing the wrong lib, you should be using mysqlclient.
pip install mysqlclient
I have a django project on my Mac using it.
Edit
You should be using virtualenv when installing pip packages.
This command worked for me
pip3 install mysqlclient==1.4.2.post1

Categories

Resources