How to change MySQL Connector installation directory? - python

I am trying to Install MySQL Connector using "pip install mysql-connector-python" but it says that
Requirement already satisfied (use --upgrade to upgrade): mysql-connector-python in /Library/Python/2.7/site-packages
I am using Python IDLE and i want to somehow install mysql-connector in IDLE`s modules directory and so MySQLdb.
How do i change the default directory which is /Library/Python/2.7/site-packages to the one used by IDLE?

You best use virtualenv, and make IDLE work in a virtual environment. This way you can just install Connector/Python as usual.
Or you can install MySQL Connector/Python in a different folder and add it to the PYTHONPATH when launching IDLE:
shell> pip install --target=/tmp/myconnpy --allow-external mysql-connector-python mysql-connector-python
shell> PYTHONPATH="/tmp/myconnpy" idle
pip 1.4.1 has apparently problems using --target when the package is already installed system-wide, even using --ignore-installed. So you'll need to remove the package first first.

Related

I installed Python for all users (Windows 10) but it still created a user installation

I'm not sure I understand what's going on here, since I create a virtual environment and it seems to be using the "all users" installation, but whenever I update pip, it does so in a user-specific folder?
I've just installed the latest Python version (using the Windows installer from python.org). I carefully selected the custom installation option and selected to add Python to environment variables and "install for all users", so I saw how the default user folder changed to C:\Program Files\Python39, as seen here:
Then I tried to update pip (from version 21.1.1 to 21.1.2) so I ran python -m pip install --upgrade pip and got this message:
Defaulting to user installation because normal site-packages is not
writeable Requirement already satisfied: pip in c:\program
files\python39\lib\site-packages (21.1.1) Collecting pip Using
cached pip-21.1.2-py3-none-any.whl (1.5 MB) Installing collected
packages: pip WARNING: The scripts pip.exe, pip3.9.exe and pip3.exe
are installed in
'C:\Users\Currentuser\AppData\Roaming\Python\Python39\Scripts' which is
not on PATH. Consider adding this directory to PATH or, if you
prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.1.2 WARNING: You are using pip version
21.1.1; however, version 21.1.2 is available. You should consider upgrading via the 'C:\Program Files\Python39\python.exe -m pip install
--upgrade pip' command.
So what's with this C:\Users\Currentuser\AppData\Roaming\Python\Python39 folder?
If I run pip --version` I get:
pip 21.1.2 from
C:\Users\Currentuser\AppData\Roaming\Python\Python39\site-packages\pip
(python 3.9)
So it looks like it has created a user-only installation in C:\Users\Currentuser\AppData\Roaming\Python\Python39?
The problem is that now I have 2 versions, and venv uses the old one. I created a C:\Users\Currentuser\Desktop\test folder and then created a virtual environment within it. In this environment, pip list shows me it uses the old pip version:
Package Version
---------- -------
pip 21.1.1
setuptools 56.0.0
WARNING: You are using pip version 21.1.1; however, version 21.1.2 is available.
You should consider upgrading via the 'c:\users\currentuser\desktop\test\my-venv\scripts\python.exe -m pip install --upgrade pip' command.
So how do I prevent Python from using this C:\Users\Currentuser\AppData\Roaming\Python\Python39 folder and force it to use the C:\Program Files\Python39\ I installed to?

pip installing in usr/lib/python3.6/site-packages instead of virtualenv on ubuntu server

I'm having a problem when installing packages on my virtualenv.It all started when I upgraded my pip to the latest version. I tried to revert my pip version to where I find it stable. When I try to install, for example, django-tables2, it says:
Requirement already satisfied: django-tables2 in /usr/lib/python3.6/site-packages (2.3.1)
Requirement already satisfied: Django>=1.11 in /usr/local/lib/python3.6/dist-packages (from django-tables2) (2.2.4)
Requirement already satisfied: pytz in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-tables2) (2019.2)
Requirement already satisfied: sqlparse in /usr/local/lib/python3.6/dist-packages (from Django>=1.11->django-tables2) (0.3.0)
WARNING: You are using pip version 19.3.1; however, version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
But when I check my folder in my virtualenv, it doesn't show there. I tried some commands like which pip and which pip3 and it says this:
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject# which pip
/home/unidaweb/unidaproject/unidaenv/bin/pip
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject# which pip3
/home/unidaweb/unidaproject/unidaenv/bin/pip3
(unidaenv) root#UnidaWebApplication:/home/unidaweb/unidaproject#
I also tried pip list but I can't find the package that I installed to my virtualenv.
I'm getting a bad gateway error when I try to add it on my settings.py, I don't really know how to fix this but when I'm in the version of pip that I know was stable running my project, I don't get this error and I can install any package that I needed to my project. Any help would be much appreciated. I'm stuck on this for about a week, hoping that someone could help me with this issue.
virtualenvs can break occasionally especially if the somebody updated the python executable the virtualenv was based or some packages / shared libraries of it.
I'd suggest to try out with a new virtualenv. (delete the broken one and replace it)
Further.
for debugging I suggest to type following two commands:
type -a python and type -a pip
In case your search path has some hidden surprises it could be safer to call
python -m pip instead of python though in a properly setup virtualenv it shouldn't make a difference.

Why is pip asking me to upgrade when it's already up-to-date?

I have a brand new installation of python 3.7.1 64-bit and I'm using the latest pyCharm as my IDE. I have no other installation of python on this machine.
I go to install numpy and I get this message:
(venv) C:\Users\John\PycharmProjects\project>pip install numpy
Requirement already satisfied: numpy in c:\users\john\pycharmprojects\pysims\venv\lib\site-packages (1.15.4)
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
So I run the suggested command but it's already up-to-date
(venv) C:\Users\John\PycharmProjects\project>python -m pip install --upgrade pip
Requirement already up-to-date: pip in c:\users\john\pycharmprojects\pysims\venv\lib\site-packages (18.1)
So I check the version but it's still the old version
(venv) C:\Users\John\PycharmProjects\pySIMS>pip -V
pip 10.0.1 from c:\users\john\pycharmprojects\pysims\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip (python 3.7)
I thought I'd try py -3 to upgrade and it works.
(venv) C:\Users\John\PycharmProjects\pySIMS>py -3 -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-18.1
But the version is still old
(venv) C:\Users\John\PycharmProjects\pySIMS>pip -V
pip 10.0.1 from c:\users\john\pycharmprojects\pysims\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip (python 3.7)
WHAT IS GOING ON? Am I missing something totally obvious? I've never had an issue like this working in Python 2 but since I've moved to Python 3 it's been nothing but errors.
This is looking like you have multiple installation of pip, one that comes first in the PATH (pip) and another that is recognized by python (python -m pip).
Try running the command:
pip show pip
and
python -m pip show pip
And check if the path are the same.
If not i would suggest uninstalling the undesired one, or change your your PATH environment variable to have the folder containing the correct pip come before the folder with the wrong one.
When I got this error I had 2 pip version folders in site-packages. One pip-19.2.3.dist-info and another something like pip-10.0.1. I deleted the first one, leaving only the default version. Then running python -m pip install --upgrade pip fixed the problem
I had a similar issue where I was upgrading pip; however, my issue what that I had a pip.conf file that pointed to a repo that didn't have the version to upgrade to. I removed the pip.conf to allow it to go to the default repo and it was able to download the correct version and upgrade.
1.Open you project setting(File>Settings)
2.Project>Project Interpreter
3.find pip and lick the triangle on the right(in the red circle I draw)

PIP Failed to create process

Python Version 2.7
On windows 10 64bits
pip install <whatever>
command not working.
C:\new_software\Python27\Scripts>python -m ensurepip
Requirement already satisfied: setuptools in c:\new_software\python27\lib\site-packages\setuptools-28.8.0-py2.7.egg
Requirement already satisfied: pip in c:\new_software\python27\lib\site-packages\pip-9.0.1-py2.7.egg
C:\new_software\Python27\Scripts>python -m ensurepip --upgrade
Requirement already up-to-date: setuptools in c:\new_software\python27\lib\site-packages\setuptools-28.8.0-py2.7.egg
Requirement already up-to-date: pip in c:\new_software\python27\lib\site-packages\pip-9.0.1-py2.7.egg
C:\new_software\Python27\Scripts>pip install wheel
failed to create process.
C:\new_software\Python27\Scripts>python -m install pip install pip
C:\new_software\Python27\python.exe: No module named install
I have python 3.x and 2.7; in 3.x pip works fine; only in 2.7 it aint.
Based on reading articles online: I have completed:
1.environment variable set up.
2.python VC++ installed
Thank you all for your response. I read the link shared by #cricket_007.
Solution:
Update all .py files [firstline] inside /Scripts folder with current path of Python Home. You will notice it will be pointing to an older location.
Then try running pip command from new CMD prompt, should work fine.

Python pip install mysql-connector-python 2.0.1 fails

In developing a Django application, I used the following command to install MySQL (python3):
(Venv)$ pip3 install mysql-connector-python --allow-external mysql-connector-python
The installation was sucessful, and pip3 freeze > requirements.txt shows that mysql-connector-python==2.0.1 was installed.
However, in the production environment, pip3 install -r requirements.txt produced the following error message.
Downloading/unpacking mysql-connector-python==2.0.1 (from -r requirements.txt (line 6))
Could not find any downloads that satisfy the requirement mysql-connector-python==2.0.1 (from -r requirements.txt (line 6))
Is this a bug?
There is an outstanding bug with the way it is packaged on PIP.
here are the details: http://bugs.mysql.com/bug.php?id=76063
You can use following commands to install mysql-connector as mentioned on same link :
wget https://cdn.mysql.com/Downloads/Connector-Python/mysql-connector-python-2.0.3.zip
unzip mysql-connector-python-2.0.3.zip
cd mysql-connector-python-2.0.3
python setup.py install
pip can not install mysql-python-connector due to an error on the part of its package maintainers. Here is the relevant issue filed against that package's bug tracker. Although technically it should be installable with
pip install --allow-external mysql-connector-python --allow-unverified mysql-connector-python mysql-connector-python
this does not work if the package maintainers fail to correctly register the external URLs to PyPI.
Note that PyMySQL appears to be a complete drop-in replacement, as a pure-Python MySQL driver that implements the Python DB API 2.0 specification. Additionally, PyMySQL appears to be actively maintained, uploaded to PyPI (as opposed to hosted on external URLs), and is under the more generous MIT license (as opposed to the GPLv2 license).
Try this if you do not want to install manually:
sudo pip3 install --extra-index-url https://pypi.python.org/pypi/mysql-connector-python/2.0.4 mysql-connector-python
Works for me on Debian Jessie.

Categories

Resources