I am trying to compile a model writte in fortran called pywofost. I followed the steps of compiling the model. however, I receive the following error related to sqlalchemy.exceptions. sqlalchemy version is '1.0.12'. the error message is as follows:
command
import pywofost
error
/usr/lib/python2.7/dist-packages/pkg_resources.py:1031: UserWarning: /home/omar/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
warnings.warn(msg, UserWarning)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/omar/pywofost/pywofost.py", line 16, in <module>
from sqlalchemy.exceptions import *
ImportError: No module named exceptions
That's because there is no module in sqlalchemy named exceptions as of version 1.0.12. If you were depending on a third party module it looks like they have a bug in their code
There is sqlalchemy.exc or sqlalchemy.orm.exc if you want to import exceptions from there though. Maybe you can just modify the pywofost code quickly and continue your work?
the problem was solved by using older version of sqlalchemy
Related
When Python fails to load a dependency of a C extension module, it shows a cryptic error message that doesn't really help you solve the issue.
>>> import mymodule
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing mymodule: The specified module could not be found.
mymodule.pyd is there, but it has a dependency on something else that is not visible to the Python executable. How can I figure out exactly what dependency is failing?
Note that I'm not looking for help on specific packages, but for a generic way to solve this issue.
Edit: Turns out python is just relaying whatever error message it gets from Windows when trying to load the dll, so I guess this is more a Windows cryptic message than Python's.
CPython dll import source code
I have a piece of code that is run on many different systems. On some systems the module pyodbc is not present so I fall back to pymssql.
I would like to test the fall back process in an environment that has both of these modules installed.
Added difficulty: pyodbc is not imported anywhere in my code, only inside sqlalchemy.
The particulars of the libraries don't matter. I would just like to avoid having to run pip to remove and replace the pyodbc module and then have to test twice.
Is there some way to spoof the module being missing?
You can fake the absence of a module by messing around with sys.modules:
>>> import sys
>>> sys.modules['pyodbc'] = None
>>> import pyodbc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: import of 'pyodbc' halted; None in sys.modules
(stolen from this answer)
I'm getting an error on importing a function from another file in python.
This is my file structure
In checkSpellings.py there's a function defined as spellchecker(tokenized_text) . And I'm trying to use it by importing it on main.py by following code
from checkSpellings import spellChecker
But it gives me an warning (red underline on top of both of checkSpellings(file name) and spellChecker(function name) in import code). This previously happened and I though this is purely an issue with intellisense . Because last time same thing happened (gave me the warning), but the code worked fine.
But now when I run the main.py it gives me an error saying
Traceback (most recent call last):
File "/home/pankaja/Documents/PycharmProjects/BookDigitizer/OCR_Correction/main.py", line 1, in <module>
from checkSpellings import spellChecker
ImportError: cannot import name 'spellChecker
How can I fix this ? What have I done wrong ?
IMPORTANT : Here I'm using python3.6 interpreter on an anaconda virtual environment. Might it be an issue ?
The function is spellchecker but you tried to import spellChecker.
My background is Java/C++ and I'm very new to python. I'm trying to import pyodbc to my project which works alright if I do it via command line.
import odbc
However, when I try to do the same in pydev/eclipse, i get the following error which I cannot find a solution to. I suspect this may have something to do with Eclipse setup
Traceback (most recent call last):
File "C:\Users\a\workspace\TestPyProject\src\helloworld.py", line 2, in <module>
import pyodbc
File "C:\Users\a\AppData\Local\Continuum\Anaconda3\Lib\site-packages\sqlalchemy\dialects\mssql\pyodbc.py", line 105, in <module>
from .base import MSExecutionContext, MSDialect, VARBINARY
ImportError: attempted relative import with no known parent package
I'm really stuck here and any hints will be appreciated!
An incorrect library was imported into the External Libraries list of the project. After fixing it, the import is working.
I was successfully using python in my programs and importing necessary modules including MySQL. However, to get IDLE on my computer I downloaded a new copy of python. I'm really not sure what I did or what happened but when I try to run a program now that uses MySQL I get the following error:
Traceback (most recent call last):
File "MyFile.py", line 11, in <module>
import MySQLdb
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so
any ideas on how to fix this?
Actually I fixed the problem by reinstalling MySQLdb following the step found here. I'm not sure how well this will work for additional modules though