So, I have an Excel workbook that I originally created on Windows 7 running Anaconda 4.1.1 (Python 3.5) and Excel 2013. Everything was working great in that environment. I am now trying to work on it remotely using a computer running Windows 10, Anaconda 4.1.1, and Excel 2016. I downloaded the workbook and its corresponding .py file, but when trying to import the UDFs in the .py file I get the following error:
(link to image)
If for some reason the link is broken, the error text is basically
ImportError: No module named 'C:\\Anaconda3\\custom_scripts\\loop_parameters'
The file's name is "loop_parameters.py" and it is found in the path "C:\Anaconda3\custom_scripts". It seems to me that somehow the name of the module (loop_parameters) is getting conflated with the path associated with it. But I have no idea how to fix that. I tried changing the UDF_PATH variable with no change in the error message at all. Thoughts?
So I ended up just starting a new project in xlwings on the new machine, copying over the python code into the new .py file, importing the UDFs, then copying the entire workbook from the old (non-functioning) book to the new one, where the UDFs worked fine. I'm still not sure what the error was or why it was happening. The workaround does seem clucky, but it only took a few minutes.
Related
I created a python application and used PyInstaller to convert it into .exe.
My problem is: I was playing around with the .exe files for practicing, And i changed the manifest name and the application doesn't work (indeed) but the wired thing is: when I re-named that manifest file to the original name. The application is still not working with the same error: '380 Ordinal not found'. And I also tried to uninstall the application and re-install it, but again still not working (BUT if I install it with a different name OR path the application will work fine).
I think it is something related to Temp files some of the settings are stored somewhere and in order to let my application work I need to clear these files (Am guessing).
So please could someone explain to me the cause of the problem and why it happened and how to resolve it?
Python 3.7,
Pyinstaller 4.5,
win 10
I found the solution: the problem happened because the manifest becomes tattooed into that executable name after the launch.
So modifying the modification date of the exe file will do the job and the application will works fine again.
Here is a python script that can fix this kind of problem:
import os
import time
import datetime
path = './/run_application//run_application.exe'
modified_ts = time.mktime(datetime.datetime.now().timetuple())
os.utime(path, (modified_ts, modified_ts))
print("Executable modification time has been updated.")
Here you can see the topic with more explanation https://github.com/pyinstaller/pyinstaller/issues/6223
I have a simple .ipynb that reads a value from one excel file, and prints it to a cell in another excel file. I use 'jupyter nbconvert --to script MyFile.ipynb to generate .py file. This works, no error. .py file is created.
In terminal:
C:\Users\me\Anaconda3\Scripts>jupyter nbconvert --to script MyFile.ipynb
Output:
[NbConvertApp] Converting notebook MyFile.ipynb to script
[NbConvertApp] Writing 1034 bytes to MyFile.py
I then go:
C:\Users\me\Anaconda3\Scripts>pyinstaller --onefile MyFile.py
I then get:
raise ImportError('Unable to load module attribute') from e
ImportError: Unable to load module attribute
This is my stop point now, and I can figure it out. I find information about adding paths etc., but I don't really understand what to do?
The history is like this, I first got 'maximum recursion depth exceeded error'. I tried to solve this by altering spec file with:
import sys
sys.setrecursionlimit(5000)
I then ran -C:\Users\me\Anaconda3\Scripts>pyinstaller --onefile MyFile.py' again, with no luck. Spec file was over-written.
I then ran 'pyinstaller MyFile.spec' this did not work.
I then found somewhere that the version of openpyxl could be the issue, and I uninstalled current version, and installed openpyxl 2.3.5. I then deleted my .py file and started over to be on the safe side. After doing this I got the above 'ImportError: Unable to load module attribute' error.
It seems like I keep moving towards getting an exe file in the end here, but it sure isn't as easy as some forums would like it to be.
What am I doing wrong? How can I improve my overall code/ setup to reach my goal of a functional exe file? I am using windows, and the users of the exe file will be windows based.
Thanks!
I was having a similar issue and for me the cause of my version of matplotlib. There appears to be a current known bug with matplotlib version 3.3.x. Downgrading to 3.1.2 fixed my issue. Also if you are using Anaconda Navigator I would recommend creating a dedicated Python environment solely for packaging your script.
I´ve made a project with python OpenCV, and used the shape_predictor_68... a .dat file.
Now when I build the project with cx_freeze, everything does right, but when I run the app build, it shows a error.
I am also facing the same issue but after some search, I get to know my shape_predictor_68_face_landmarks.dat is not updated or correct so I replace it with another and issue resolved, the link for the new shape_predictor_68_face_landmarks.dat file is
https://github.com/AKSHAYUBHAT/TensorFace/blob/master/openface/models/dlib/shape_predictor_68_face_landmarks.dat
replace the new file with older one.
Referring the solution to a similar issue here
If you are getting this error:
RuntimeError: Unable to open /home/lyz/openface-master/demos/web/../../models/dlib/shape_predictor_68_face_landmarks.dat
You probably haven't downloaded dlibs models properly, perform Step 4 from https://cmusatyalab.github.io/openface/setup/ again. In short, cd into your openface library and run
./models/get-models.sh
Also, I can't tell how you are running this but it could also be a case that the library may not be correctly imported in your current venv - where your interpreter is.
Install dlib correctly and just paste this .dat file in the same working directory as your code is present and try to run the code.
The link is
http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
You can find the .dat file here after extracting a WinZip file that can be downloaded from the dlib.net website.
I've written a simple python script that uses openpyxl to read IP's out of an excel file and does a whois lookup on it and writes the results to a new excel file. Everything works great in Spyder but when I package it as an exe using pyinstaller I get an error when I run the exe.
The traceback says "'Worksheet' object has no attribute 'values'" like it's not reading the values from the original excel file. I've tried using the full path of the file but still get the same error. The excel file is in the same directory as the exe. Do I need to package the exe in a different way? Specifically tell it to package the openpyxl library?
I've done a lot of googling and can't find much info. Any help is appreciated! Thank you
Thanks for your time. Im an old programmer coming back to Python
I have a new install of Anaconda3, Windows 10 and Microsoft Office 2010
I tried install xlwings via pip straight into Python3 - didn't seem to work
Ive then installed anaconda3, spyder.
Ive installed inside anaconda at the command prompt
xlwings addin install
xlwings addin update
initially I got an error going into excel, saying 2 spreadsheets of the same name can not be open - I guess that was something to do with when I was trying to get the original python3 / pip/ addin manager to work....
Ive spent all day trying to sort that. It no longer appears in the addin menu (developer), just in the ribbon - xlwings
Ive run a program as per the documentation spyder/python and get Hello xlwings inside excel (created the python and excel spreadsheet with the xlwings quickstart myproject)
But when I try and use a fuction that sends data to python I get an error. if I click on run main, import functions or restart UDF server I get a missing DLL error
Run Time error 53 - file not found xlwings32.0.19.2.dll.
ive tried copying it to System32, removing the addin (xlwings addin remove) and reinstalling it
I completely unsinstalled Microsoft office and reinstalled it - the addins was still there anyway !
Sorry a lot of explanation for what is actually a DLL issue, but ive been going around and around for hours.
So in summary, I don't had xlwings under the addins/developer in excel, but it does appear on the ribbon. I can run a python program that puts "hello world" into excel but excel does not recognise the python function and when I try and interact with excel I get a missing .dll error.
What should I do ? rip out python / accoconda etc and start all over again ?
cheers
Older and Greyer !
I don't know if this will fix your problem, I was having the same error with Excel's "sorry you can't have two workbooks of the same name open at the same time" and solved it. The error only happened when the Excel add-in "xlwings" was checked. I fixed the error by moving the location of the xlwings add-in from C:\Users\MYNAME\AppData\Roaming\Microsoft\Excel\XLSTART where it had automatically put itself to C:\Users\MYNAME\AppData\Roaming\Microsoft\AddIns.