I'm using CentOS release 6.5 (Final).
I 'm currently using python 2.4, in which I can use MySQL without problems.
root#dedicado [/home/digicelc/public_html/gestion/python/cater]# python
>>> import MySQLdb
>>>
But, when I try it from python2.7
root#dedicado [/home/digicelc/public_html/gestion/python/cater]# python2.7
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named MySQLdb
>>>
I don't want to change the python version in the server, just want to make the module avaiable for 2.7
Finally this:
# yum install python27-MySQL-python
Is giving me this:
Error: Package: python27-MySQL-python-1.2.3-9.el6.centos.alt.x86_64 (scl)
Requires: libmysqlclient_r.so.16()(64bit)
Error: Package: python27-MySQL-python-1.2.3-9.el6.centos.alt.x86_64 (scl)
Requires: libmysqlclient_r.so.16(libmysqlclient_16)(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
I had a similar problem. Had to install python2.7 to get a particular library, then couldn't run mysql via python2.7 because it was installed on 2.6.
Try this:
pip2.7 install MySQL-python
Related
I wanted to use turicreate library which doesn't support python 3.8 yet. So tried downgrading python to 3.7 using
downgrade python
But now I cant use pip. Even a simple command using pip like,
pip --version
gives me an error:
Traceback (most recent call last):
File "/usr/bin/pip", line 6, in <module>
from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'
I have already tried downgrading pip to 19.0.3.
Also tried uninstalling and reinstalling both packages.
What can I possibly do? I use Arch Linux btw.
Instead of downgrading python for the whole OS, may be you should try using a downgraded python version for just your project.
Try using a virtual environment and use it to create a dev environment with python 3.7.
I am trying to install Pytorch via pip on ubuntu 18.04.I have python 3.6 and my laptop is HP-Pavilion notebook 15
The installation seems to be right because i get the message:
Installing collected packages: torch, torchvision Successfully
installed torch-1.3.1+cpu torchvision-0.4.2+cpu
i run the verification code and it is ok
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
However, when i close the terminal or reboot and try to run he same code i get the error:
Traceback (most recent call last):
File "torch.py", line 2, in
import torch
AttributeError: module 'torch' has no attribute 'rand'
How are you executing the python script? Which python are you using? Maybe you installed the package in a different python version?
Try to set alias to the python you want to use:
alias python=/usr/local/bin/python3.6
Then pip install the package with that python alias you will always be using.
python pip install <package name>
Python now will install the package in the python files with the alias python - heading to files: /usr/local/bin/python3.6
Let me know if the error still occurs!
Install pytorch using pip through the below command:
pip3 install torch==1.3.1+cpu torchvision==0.4.2+cpu -f https://download.pytorch.org/whl/torch_stable.html
for any reference go through the official website of pytorch.
Change your file .py to another name, you named torch.py when you import torch it will call ur torch.py
I tried to install redis-py lib via pip. It was installed successfully, but when I tried to import redis in python3 shell, I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'redis'
In python2 it gets imported with no errors.
I have tried all three pip, pip2, pip3 on my machine (ubuntu 17.10). Also I have python3.6 installed. I also tried easy_install
You are installing it in Python 2.7 (you have probably already know this). If python3.6 brings up the correct Python version on your system then this should work for you:
python3.6 -m pip install redis
If you are unsure what each pip version brings up you can use the which command to list the file path. This will give you a good indication as to where to look.
Also pip3.6 install redis might work but is not as secure as the above
I need to install Python 2.7 on a machine, from source, alongside the existing version on the machine (2.4). I have compiled and installed Python successfully, but when I try to run a script calling the MySQLDB module, it throws the following error:
[root#the-node1 bin]# interactive_recording_archive.py
Traceback (most recent call last):
File "/usr/local/bin/interactive_recording_archive.py", line 8, in <module>
import MySQLdb as mdb
ImportError: No module named MySQLdb
I have tried installing MySQLDB using the easy-install script but this fails to find any module by that name. I have MySQL installed and working on the machine.
What am I doing wrong?
The package is called MySQL-python:
easy_install MySQL-python
Do check the installation requirements; you have python and setuptools, but you need the mysql-devel package too.
i am new to python, on my Mac, when i issue command
User:ihasfriendz user$ python main.py
Traceback (most recent call last):
File "main.py", line 2, in <module>
import json
ImportError: No module named json
I get error on json. how to add this library? i'm using 2.5 (the default came with leopard)
You can also install simplejson.
If you have pip (see https://pypi.python.org/pypi/pip) as your Python package manager you can install simplejson with:
pip install simplejson
This is similar to the comment of installing with easy_install, but I prefer pip to easy_install as you can easily uninstall in pip with "pip uninstall package".
AFAIK the json module was added in version 2.6, see here. I'm guessing you can update your python installation to the latest stable 2.6 from this page.
You can also install json-py from here http://sourceforge.net/projects/json-py/