MySQLdb import error Enthought Canopy - python

I'm about to lose my mind over this one, so any help is much appreciated.
I'm working with win8.1, and Enthought Canopy Python 2.7.6 that I'm running from the command line. I initally had difficulties installing MySQLdb, but eventually the MySQL‑python‑1.2.5.win‑amd64‑py2.7.exe installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python worked.
Stupidly a few weeks later there was something that wouldn't work in MySQLdb 1.2.4 so I used pip to roll it back to 1.2.4 and now it's gone - anytime I run programs I get 'import error: No module named MySQLdb'
I've tried pip, easy_install, installing from sources, that installer from above again, with no avail. It's saying that it's installed, it's in CP add/remove programs. When I run pip install MySQL-python:
Requirement already satisfied (use --upgrade to upgrade): MySQL-python in c:\use
rs\laura\appdata\local\enthought\canopy\user\lib\site-packages
Cleaning up...
When I navigate to that directory there are two mysqldb folders named - mysqldb - contains - constants, init, connections, converters, cursors, release, times
and mysql_python-1.2.5-py2.7.egg-info - contains - dependency_links, PKG-INFO, SOURCES, top_level
Thanks in advance for any help,
Laura
EDIT:
I ended up working around the problem by using pymysql instead.

I have MySQLdb module locally installed and can run scripts with it in the command line just fine, but when I run scripts with the MySQLdb module in the Canopy IDE then it does not work. I would check to see if MySQLdb module is an installed package on Canopy because im pretty sure (could be wrong) that you have to subscribe to canopy to get that module. Hope that helps

Related

CQLSH ImportError: cannot import name ensure_str

I have installed Cassandra database on my CentOs system. after that, I tried to install the Cqlsh package using this command sudo yum install cqlsh and it has been installed successfully. but when I tried to run cqlsh from the terminal, the following error appears:
ImportError: cannot import name ensure_str
somewhere in the code, it tries to load a library named six that contains ensure_str. the error does not say that it can not find a module named six, the python interpreter can find the library but can not import it!
I have tried googling but none of the solutions worked for me.
after a few hours of googling and struggling with the code, finally, I find out the solution. and I'm going to share it with others.
apparently, the problem is the new version of six (v=1.7.3) which is not compatible with my system. However, Cassandra copies the last version of six into the following path:
/usr/share/cassandra/lib/six-1.7.3-py2.py3-none-any.zip
then cqlsh try to force the python interpreter to import the library from this path by adding the following lines to the code.
third_parties = ('futures-', 'six-', 'geomet-')
for lib in third_parties:
lib_zip = find_zip(lib)
if lib_zip:
sys.path.insert(0, lib_zip)
no matter if you have another version of six installed on your system, it always tries to import the library from the Cassandra folder.
So, I have just deleted these lines from cqlsh file using this command:
vim /usr/bin/cqlsh
Then I try to install the last compatible version on six using this command:
yum install six
That's it! problem solved and now I'm using cqlsh without any problem.
I hope it helps others.
We've had reports of this being a problem on CentOS specifically with version 6.7 but it possibly affects the 7.x releases too.
It appears that the wrong Python is getting called. This isn't strictly a Cassandra issue but a problem with the Python on the machine. You can verify which Python gets run with:
$ which python
As a workaround, you should be able to run cqlsh using the system Python as follows:
$ /usr/local/bin/python /usr/bin/cqlsh
Cheers!
Use pip3 to install or upgrade to the current six.
Edit a copy of cqlsh. Change
third_parties = ('futures-', 'six-', 'geomet-')
to
third_parties = ('futures-', 'geomet-')
Not proud, but it worked.
Used pip3 to install, and found this issue as well.
For me, removing six dependencies from /usr/lib/python3/dist-packages was the only thing that worked.
rm six-1.11.0.egg-info and rm -r six-1.11.0.egg-info
I couldn't uninstall it with pip3, so manual removal was the way to go, followed by a pip3 install six
Once that was back in place, cqlsh ran without issue.
The previous answers didn't work for me, I had to delete the Cassandra included six package, and then cqlsh used the system-wide package.
mv /usr/share/cassandra/lib/six-1.7.3-py2.py3-none-any.zip /usr/share/cassandra/lib/six-1.7.3-py2.py3-none-any.zip.bak
Maybe an older version of Cassandra installed, and a newer version of cqlsh?
https://community.datastax.com/questions/12085/unable-to-connect-to-cqlsh.html

What is the reason of ModuleNotFoundError: No module named 'mysql' in Python 3.8.10 and Requirement already satisfied in anaconda location problem?

I need to import mysql-connector and I installed it by using pip install mysql-connector-python.
After the installation, I can see the same error is displayed.
After that again I tried to install mysql connector, but it displayed that Requirement already satisfied and show a path in anaconda lib folder.
Is there any effect from previous installation on Anaconda and how to import mysql-connector to code?
As a solution for that, I changed the interpreter of the code into ('base': conda). It worked correctly without any error.

Python module shows up in pip freeze, but cannot be imported

I'm in Win10 and use vanilla Python 3.7.3 (e.g. not conda or anything). I had a successful pip install for the package, the package shows up in pip freeze, and the package is supposed to be compatible with my version of Python. I've seen several threads with similar issues on OS X and Linux, and have tried to emulate their solutions on Windows, but no luck. I'm guessing it could be an issue with my PATH variable, but I'm not quite sure. The error I get when trying to import is the "No module named" error.
Went into site-packages...for some reason the module was named Bio there (everywhere else it's named biopython, again, including pip freeze) and importing that worked. Not sure if this was just a bad dev choice or what.

Pycharm Error - No module named MySQLdb

I have installed MySqldb as shown below:-
jab-MacBook-Pro-4:silkroute deb$ pip install MySQL-python
Collecting MySQL-python
Installing collected packages: MySQL-python
Successfully installed MySQL-python-1.2.5
But still I am getting the error:-
python --version
Python 2.7.11
I am using version 2.7.10 in PyCharm
I have also installed MySQLDB as shown below:-
jab-MacBook-Pro-4:silkroute deb$ pip2.7 install MySQL-python
Requirement already satisfied: MySQL-python in /usr/local/lib/python2.7/site-packages
Can someone let me know how can I get rid of this error?
Your Pycharm was not using the right python environment.You can change the project interpreter by setting Pycharm.
Step:File-> SettingsIn Popup menu: Project-> Project Interpreter-> add or create virtualenv environment
After changing project interpreter, the Pycharm has many function to use
Open PyCharm, File>>Default Settings>>Project Interpreter>>Select the Interpreter you want to install the packages to, press the red '+' sign to the right, search the package and install.
This should most probably correct your error. You are better off creating a virtualenv though, will be really helpful. Use this to get started
You may have multiple Python versions installed.
Use pip2.7 to see if this installs on the right python version.
Check this post: pip: dealing with multiple Python versions?

Setuptools error when trying to install a package

I’m completely new to Python and I want to install the package py-webrtcvad in Windows 7, but I'm stuck at the error ImportError: No module named 'pip.utils.setuptools_build'. There is an answer to this problem in stackoverflow which seems to solve the problem for others, but it doesn't work for me.
Here’s a summary of what I’ve done and tried so far:
Installed Python 3.5 and set up the Windows path environment so
that it works from any directory.
Installed pip for Python.
Tried to install the package with python -m pip install webrtcvad,
but it failed, returning the error Unable to find vcvarsall.bat.
I found a blog that deals with the vcvarsall.bat
problem: blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat. Following the directions of that blog:
First I just installed Visual C++ Build Tools 2015 and tried installing the package straight away (without updating setuptools), but I received a lot of error messages (which I didn’t write down).
I tried reinstalling setuptools, which I did following the directions in https://pypi.python.org/pypi/setuptools: I removed the version of setuptools that came with my Python installation (v20), and installed the latest version (v30). This time I got a different error message when trying to install py-webrtcvad: ImportError: No module named 'pip.utils.setuptools_build'.
Asked for assistance in the Python official chat. They made three
suggestions:
Updating pip with python -m pip install --upgrade pip. Didn’t
work. Again, the error ImportError: No module named 'pip.utils.setuptools_build'.
Reinstalling Visual C++ Build Tools 2015. No difference, same error
again.
Reinstalling Python itself. The Python installer offers three
choices: Repair, modify and uninstall.
Repair: Didn’t work. Same error.
Modify: Doesn’t look like it offers useful modifications for this.
Uninstall: Uninstalled and reinstalled. Still the same error.
I’m out of ideas. Can you help me?
Note: I imagine this should be doable in Windows 7 with Python 3.5. However, if it isn't I'm open to trying anything different. For example, installing a different version of Python would be no problem at all. I could also try installing Linux if that will solve the problem.
There was a bug in version 2.0.8 of webrtcvad that caused it to use the wrong flags when compiling for Windows: it was using -DWEBRTC_POSIX instead of -DWIN32. This might have been the source of the "lot of error messages" you got during one of your early attempts.
The fixed version has been pushed to pypi as version 2.0.9. I've confirmed that pip install webrtcvad works correctly on Windows 10. I'm using a pretty fresh install of Python, so I would try it first without reinstalling setuptools.

Categories

Resources