python USER_BASE error - python

I am using python 2.6 and trying to install django tagging package and i get this error below.I am installing few python 2.4 packages on a 64 bit machine which already has python2.6.
How to resolve this error
[root#tom django-tagging-0.3.1]# python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from distutils.command.install import INSTALL_SCHEMES
File "/usr/lib64/python2.6/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
ImportError: cannot import name USER_BASE
EDIT 1
[root#tom django-tagging-0.3.1]# python2.6 setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from distutils.command.install import INSTALL_SCHEMES
File "/usr/lib64/python2.6/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
ImportError: cannot import name USER_BASE
EDIT2
>>> from distutils.sysconfig import get_python_lib
>>> print(get_python_lib())
/usr/lib/python2.6/site-packages
EDIT3
>>> import site ; print site
<module 'site' from '/opt/mysite/site/__init__.pyc'>

You've called one of your Django apps "site". This is shadowing the site module in the stdlib. Rename it.

Related

cannot import name 'etree' from 'lxml' in home brew installed package but fine in python shell

I'm trying to run ocrmypdf which was installed via homebrew but am having issues with my local version of lxml (version 4.2.4):
Traceback (most recent call last):
File "/usr/local/bin/ocrmypdf", line 5, in <module>
from ocrmypdf.__main__ import run
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/ocrmypdf/__init__.py", line 18, in <module>
from . import helpers, hocrtransform, leptonica, pdfa, pdfinfo
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/ocrmypdf/pdfa.py", line 38, in <module>
import pikepdf
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/pikepdf/__init__.py", line 54, in <module>
from .models import (
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/pikepdf/models/__init__.py", line 13, in <module>
from .metadata import PdfMetadata
File "/usr/local/Cellar/ocrmypdf/9.8.2/libexec/lib/python3.8/site-packages/pikepdf/models/metadata.py", line 17, in <module>
from lxml import etree
ImportError: cannot import name 'etree' from 'lxml' ($HOME/anaconda3/lib/python3.7/site-packages/lxml/__init__.py)
If I open up a python shell, I'm able to import just fine:
>>> from lxml import etree
>>> etree.__file__
'$HOME/anaconda3/lib/python3.7/site-packages/lxml/etree.cpython-37m-darwin.so'
My pythonpath:
$HOME/anaconda3/lib/python3.7/site-packages:$HOME/Code_Repos/invoice2data//src:$HOME/Code_Repos/invoice2data//src/invoice2data:$HOME/anaconda3/lib/python3.7/site-packages:$HOME/Code_Repos/invoice2data
I'm not sure why the homebrewed package is not picking up the module file even though it says it's pointing to the same site-packages folder.

Python toolkit mb_protocol module not found error

I just have installed wxPython and python toolkit 18.08 in Ubuntu 20.04.But,while runnimg from command line python PTK.pyw, I got an error as below
> Traceback (most recent call last):
File "PTK.pyw", line 10, in <module>
import ptk_lib.app as app
File "/home/jobayer/下载/PythonToolkit-18.08/ptk_lib/app.py", line 17, in <module>
from ptk_lib.message_bus.mb_node import MBLocalNode
File "/home/jobayer/下载/PythonToolkit-18.08/ptk_lib/message_bus/mb_node.py", line 14, in <module>
import mb_protocol
ModuleNotFoundError: No module named 'mb_protocol'
I did not find mb_protocol module any where.Where can I find this module?

python3 and RO package and DS9

How to get RO package working in Python 3? I managed to get it to work in Python 2.7, but when I install it manually as python3 setup.py install and then do import RO.DS9 I get this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/DS9.py", line 160, in <module>
import RO.OS
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/OS/__init__.py", line 7, in <module>
from .OSUtil import *
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/OS/OSUtil.py", line 31, in <module>
import RO.SeqUtil
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/SeqUtil.py", line 33, in <module>
import UserString
ImportError: No module named 'UserString'
>>> exit()
In Python 3, UserString is part of the collections module.
As you can see on the RO page, this library does only support Python 2.6 and 2.7.

Python2.7: No module named zlib

I'm trying to use matplotlib in Python 2.7, but am encountering the following error
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 156, in <module>
File "/usr/lib/pymodules/python2.7/matplotlib/cbook.py", line 15, in <module>
File "/usr/local/lib/python2.7/gzip.py", line 9, in <module>
import zlib
ImportError: No module named zlib
I installed python with sudo apt-get install python2.7, and other required packages similarly. I installed zlib from source, with no issues.

Python3.2: Installing MySQL-python fails with error "No module named ConfigParser"

I want to use SQLAlchemy with MySQL database. I've created the Engine and tried to connect but I get an error as follows.
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
Engine = create_engine('mysql+mysqldb://dbuser:pass#localhost/mydb')
Base = declarative_base(Engine)
That fails with the error:
File "/usr/local/lib/python3.2/dist-packages/SQLAlchemy-0.8.0b2-py3.2.egg/sqlalchemy/connectors/mysqldb.py", line 57, in dbapi
return __import__('MySQLdb')
ImportError: No module named MySQLdb
Searching for that I found that you have to have to install MySQLdb for python to play nice with MySQL. So trying to install it with either pip-3.2 or easy_install-3.2 fails as below.
sudo pip-3.2 install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/tmp/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named ConfigParser
I then figure I have to install configparser so when I try to do so it also fails
Original exception was:
Traceback (most recent call last):
File "<string>", line 3, in <module>
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.34-py3.2.egg/setuptools/__init__.py", line 2, in <module>
from setuptools.extension import Extension, Library
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.34-py3.2.egg/setuptools/extension.py", line 2, in <module>
import distutils.core
File "/usr/lib/python3.2/distutils/core.py", line 19, in <module>
from distutils.config import PyPIRCCommand
File "/usr/lib/python3.2/distutils/config.py", line 8, in <module>
from configparser import ConfigParser
File "configparser.py", line 122
So, my original issue is trying to get Python to work with MySQL. But trying to resolve that I can't be able to install MySQLdb.
EDIT
Gone ahead as instructed by #robertklep below and installed pymsql3.
sudo pip-3.2 install pymysql3
Regards,
MySQLdb doesn't have Python 3 support. Try an alternative which has, like PyMySQL (which is supported by SQLAlchemy as well).
EDIT: there's also this project.
https://www.pythonanywhere.com/wiki/UsingMySQL
pip install --user https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-1.1.6.tar.gz
Then, update your settings.py to use the oracle django backend, "mysql.connector.django":
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
...

Categories

Resources