Want to delete python from my server, Using Centos 7. i have python 2.6.6 and python 3.6 in my server and i think thats the reason i am getting an error. so want to remove python 2.6. i am getting these version error so want to try removing python 2.6.6 and then running my code
File "chatbot.py", line 7, in <module>
import sqlite3
File "/home/pythondemo/.local/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/home/pythondemo/.local/lib/python3.6/sqlite3/dbapi2.py", line 50, in <module>
version_info = tuple([int(x) for x in version.split(".")])
NameError: name 'version' is not defined
Uninstalling the system provided Python is a bad idea. There are many other packages and softwares that depend on it like "yum". It'll be better that you use python3.6 by either modifying the $PATH or creating an alias e.g. python3.6 that points to the python that you installed in /opt dir
Related
I want to make a Yocto image for my hardware (i.e. IMX8) according to this manual:
https://github.com/compulab-yokneam/meta-bsp-imx8mm/blob/iot-gate-imx8_r3.1/README.md
I installed python3, and python2 on my Linux (Ubuntu 22.04) that is run on on VMWare virtual machine.
I configure my python using update-alternatives and I can alter and check the Python version, and every thing is correct. But I encounter with the following message when I run the bitbakecommand:
Traceback (most recent call last):
File "/home/sap1359/compulab/sources/poky/bitbake/bin/bitbake", line 19, in <module>
import bb
File "/home/sap1359/compulab/sources/poky/bitbake/lib/bb/__init__.py", line 128, in <module>
from bb import fetch2 as fetch
File "/home/sap1359/compulab/sources/poky/bitbake/lib/bb/fetch2/__init__.py", line 26, in <module>
import bb.persist_data, bb.utils
File "/home/sap1359/compulab/sources/poky/bitbake/lib/bb/persist_data.py", line 22, in <module>
from collections import Mapping
ImportError: cannot import name 'Mapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
When I try to track another tutorial for other hardware or even for a simple X86 Yocto image,there is something the same as this error cannot import name 'someting' from 'collections'.
I also tried using virtualenv and setting up an virtual environment, however, the Import error persist.
I checked using Ubuntu 18.04, everything was OK.
According to my tests, this Yocto project can't work with Python3.10 and above, however, works in Ubuntu 22.04 by installing another version of Python3 such as 3.8.
I just want to mention that this Yocto source just uses Python3.5, or above.
I am trying to install py2neo module but ending with below error. Please help me to resolve it.
(base) C:\Users\ADMIN>pip install py2neo Collecting py2neo Using cached https://files.pythonhosted.org/packages/cd/79/a77cc0ad86c021c25dac9f52a0cd33f6832c6af7fa5e58f4438d781ae9c3/py2neo-4.0.0.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\admin\appdata\local\temp\pip-install-xj8t67\py2neo\setup.py", line 25, in <module>
from py2neo.meta import __author__, __email__, __license__, __package__, __version__
File "py2neo\__init__.py", line 19, in <module>
from py2neo.data import *
File "py2neo\data.py", line 26, in <module>
from py2neo.cypher import LabelSetView, cypher_repr, cypher_str
File "py2neo\cypher\__init__.py", line 36, in <module>
from py2neo.internal.collections import SetView
File "py2neo\internal\collections.py", line 24, in <module>
from py2neo.internal.compat import bytes_types, string_types
File "py2neo\internal\compat.py", line 45, in <module>
DEVNULL = open(devnull, "rw")
ValueError: Invalid mode ('rw')
Command "python setup.py egg_info" failed with error code 1 in c:\users\admin\appdata\local\temp\pip-install-xj8t67\py2neo\
I tried to upgrade setuptools and pip too but didn't able to install py2neo after that also.
My python version is 2.7 and working on win 10 OS.
try this as well :
This is the basic requirements :
Python 2.7 / 3.4 / 3.5 / 3.6 / 3.7
Neo4j 3.2 / 3.3 / 3.4 / 3.5 (the latest point release of each version is recommended)
pip install git+https://github.com/technige/py2neo.git#egg=py2neo
This is a bug in the library. It is illegal to open a file with mode "rw", and they're clearly doing it. You can see the code here. It should almost certainly be using "r+" here.
It's worth noting that this piece of code only runs on old versions of Python, before subprocess.DEVNULL was added in 3.3. While 2.7 is still listed as officially supported, it seems to be in "legacy mode", with a bunch of "compat" code that tries to make 2.7 act like 3.3+, including this line, and some of that compat code is probably not heavily tested.
Also, this piece of code may only be needed on Windows. If so, as the README says:
Note also that Py2neo is developed and tested under Linux using standard CPython distributions. While other operating systems and Python distributions may work, support for these is not available.
So, the fact that their 2.7 compat code is broken on a platform they don't support isn't all that surprising…
What can you do about it?
Try running Python 3.7 or 3.6 instead of 2.7. That will definitely eliminate this problem, and possibly others that you haven't run into yet.
Run a linux VM (/container/user-mode kernel/whatever), and install Python (ideally 3.7) and py2neo under linux. This will definitely eliminate this problem, and possibly others.
Fix the bug yourself and submit a pull request.
File a bug report and wait and see if someone fixes it.
I would like to have an interface between Python and sqlite. Both are installed on the machine. I had an old version of Python (2.4.3). So, pysqlite was not included by default. First, I tried to solve this problem by installing pysqlite but I did not succeed in this direction. My second attempt to solve the problem was to install a new version of Python. I do not have the root permissions on the machine. So, I installed it locally. The new version of Python is (2.6.2). As far as I know this version should contain pysqlite by default (and now it is called "sqlite3", not "pysqlite2", as before).
However, if I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/verrtex/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
It has to be noted, that the above error message is different from those which I get if I type "from blablabla import *":
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named blablabla
So, python see something related with pysqlite but still has some problems. Can anybody help me, pleas, with that issue?
P.S.
I use CentOS release 5.3 (Final).
On Windows, _sqlite3.pyd resides in C:\Python26\DLLs. On *nix, it should be under a path similar to /usr/lib/python2.6/lib-dynload/_sqlite3.so. Chances are that either you are missing that shared library or your PYTHONPATH is set up incorrectly.
Since you said you did not install as a superuser, it's probably a malformed path; you can manually have Python search a path for _sqlite3.so by doing
import sys
sys.path.append("/path/to/my/libs")
but the preferred approach would probably be to change PYTHONPATH in your .bashrc or other login file.
You have a "slite3.py" (actually its equivalent for a package, sqlite3/__init__.py, so import sqlite3 per se is fine, BUT that module in turns tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. It should be in python2.6/lib-dynload under your local Python root, AND ld should be instructed that it has permission to load dynamic libraries from that directory as well (typically by setting appropriate environment variables e.g. in your .bashrc). Do you have that lib-dynload directory? What's in it? What environment variables do you have which contain the string LD (uppercase), i.e. env|grep LD at your shell prompt?
D:\PythonPack\MySQL-python-1.2.3>python setup.py install
Traceback (most recent call last):
File "setup.py", line 15, in <module>
metadata, options = get_config()
File "D:\PythonPack\MySQL-python-1.2.3\setup_windows.py", line 7, in get_confi
g
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_ke
y'])
WindowsError: [Error 2] The system cannot find the file specified
I am trying to install mysqldb for python in windows7 and run into that error message
Do you have an idea how I can make it work ? I already have pythonsetuptool installed
Actually there are many ways and i tried them for few hours and realize its time waste process bcoz MYSQLdb is vary from version to version i.e 2.6,2.7 and 3.2 but all those are confuse and time waste processes,
Instead best way is to get precompiled executables from : http://www.lfd.uci.edu/~gohlke/pythonlibs .
here choose version wise links like python 2.7 and 32bit so that you won't get any errors and now run the downloaded file, finally set path in environment variables.
Now open python IDLE editor or from command prompt c:>python
import MySQLdb
if u don't get any errors then it's working fine...enjoy with u r work
Just install with the exe from here.
And maybe you can find more information about this in the previous asked questions like this.
I would like to have an interface between Python and sqlite. Both are installed on the machine. I had an old version of Python (2.4.3). So, pysqlite was not included by default. First, I tried to solve this problem by installing pysqlite but I did not succeed in this direction. My second attempt to solve the problem was to install a new version of Python. I do not have the root permissions on the machine. So, I installed it locally. The new version of Python is (2.6.2). As far as I know this version should contain pysqlite by default (and now it is called "sqlite3", not "pysqlite2", as before).
However, if I type:
from sqlite3 import *
I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/verrtex/opt/lib/python2.6/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
File "/home/verrtex/opt/lib/python2.6/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named _sqlite3
It has to be noted, that the above error message is different from those which I get if I type "from blablabla import *":
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named blablabla
So, python see something related with pysqlite but still has some problems. Can anybody help me, pleas, with that issue?
P.S.
I use CentOS release 5.3 (Final).
On Windows, _sqlite3.pyd resides in C:\Python26\DLLs. On *nix, it should be under a path similar to /usr/lib/python2.6/lib-dynload/_sqlite3.so. Chances are that either you are missing that shared library or your PYTHONPATH is set up incorrectly.
Since you said you did not install as a superuser, it's probably a malformed path; you can manually have Python search a path for _sqlite3.so by doing
import sys
sys.path.append("/path/to/my/libs")
but the preferred approach would probably be to change PYTHONPATH in your .bashrc or other login file.
You have a "slite3.py" (actually its equivalent for a package, sqlite3/__init__.py, so import sqlite3 per se is fine, BUT that module in turns tries to import _sqlite3 and fails, so it's not finding _sqlite3.so. It should be in python2.6/lib-dynload under your local Python root, AND ld should be instructed that it has permission to load dynamic libraries from that directory as well (typically by setting appropriate environment variables e.g. in your .bashrc). Do you have that lib-dynload directory? What's in it? What environment variables do you have which contain the string LD (uppercase), i.e. env|grep LD at your shell prompt?