when I try to run code regarding retrieving column letter from a number I keep getting the following error:
AttributeError: module 'openpyxl.cell' has no attribute 'get_column_letter'
This is the code I am trying to run:
print(openpyxl.cell.get_column_letter(26))
I expect this to run with no error.
Because this attribute has been moved to utils within this module, the way to call this without getting an error is to call it from its new location:
print(openpyxl.utils.cell.get_column_letter(26))
This should be working now.
Related
I am having a problem with embedding python script in my c++ code. It's very similar to this one: Python 3 Import error AttributeError: '_ModuleLock_' object has no attribute 'name' although there was no c++ code involved. Btw that issue was never resolved. Here is standar c++ code, nothing unusual there:
PyRun_SimpleString("sys.path.append(\"/home/me/my-project\")\n"
"sys.path.append(\"/home/me/venv/lib/python3.7/site-packages\")\n"
"sys.path.append(\"/usr/local/lib/python3.7\")\n"
"sys.path.append(\"/usr/local/lib/python3.7/lib-dynload\")\n"
"sys.path.append(\"/usr/local/lib/python3.7/site-packages\")");
PyObject* moduleName = PyUnicode_FromString("my_module");
pModule = PyImport_Import(moduleName);
Py_DECREF(moduleName);
my_module has a couple of import statement to other libraries which are I think irrelevant. What's important I think is that the same import statement sometimes succeeds and sometimes fails so it's not deterministic and the problem seems to be only related to the packages from virtual env and not the standard python packages. The code runs fine if invoked from python. The error is of course:
File "<frozen importlib._bootstrap>", line 117, in repr
AttributeError: '_ModuleLock' object has no attribute 'name'
Failed to load "/home/me/my-project/my_module.py
Please help
Ok so after a few days I finally resolved the issue. It turned out to be similar to the issue with IDLE. In my case it was tracing function that tried to access arguments of each function call at print them, thus tried to use repr function before the object had been initialized.
I'm trying to use the dataset module in python.
import dataset
# connecting to a MySQL database with user and password
db = dataset.connect('mysql://root:Kradz579032!!#localhost/aliexpressapidb')
But I keep getting the following error :
AttributeError: module object has no attribute 'connect'
What does it mean?
Thank you for posting your Traceback.
The error message shows that you've named your file dataset.py:
File "/Users/reezalaq/Downloads/newali/db/dataset.py"
This masks the module you want to import, here dataset. To solve this, just rename your file to something else.
I am three weeks into my independent study Python course, and am having trouble getting passed an issue. I am trying to use the function enterbox() from easygui I write:
import easygui
value = easygui.enterbox("say something")
And when I run it I get the error:
**AttributeError: 'module' object has no attribute 'enterbox'
Does anyone know why this may be happening? Thanks! (I'm using version 2.7)
I'm trying to use cubehelix in python however I've been getting simple problems which I don't think should be showing up. The code I'm using is the following:
import matplotlib.pyplot as plt
import numpy as np
import cubehelix
cx1 = cubehelix.cmap(reverse=True)
alplot = plt.imshow(rtotal_rotated,vmax=1100,extent[-21,19,23,-17],cmap=cx1)
However the following error comes up when I run the code:
AttributeError: 'module' object has no attribute 'cmap'
I know this can't be right since I'm simply following the code from this tutorial
http://www.ifweassume.com/2014/04/cubehelix-colormap-for-python.html
So I'm not sure why it's breaking.
Very like that the script imports itself, i.e. your script is named cubehelix.py. So, if you have file named cubehelix.py in your current working directory, rename it to my_cubehelix.py and try again.
So I have two files: main.py file and a debugModule.py. The debugModule.py file has a class named Debug(). This class has a method, update(), that I want to use in main.py. How would I do this?
In main I use import debugModule, debug = debugModule.Debug(), and then debug.update() in order to execute this method, however this just throws an error:
File "C:\Users\Nisse\workspace\Platformer\src\main.py", line 5, in <module>
debug = debugModule.Debug()
AttributeError: 'module' object has no attribute 'Debug'
I've looked around Stackoverflow for answers but I can't get it to work.
How can i use a function from another module in my main.py?
Edit: Turns out I completely messed up the names. Edited again, now they're correct.