I'm new to pyinstaller and trying to package a script I wrote that connects to Smartsheet. The code runs fine in PyCharm, but when I go to run the executable that it outputs the client object is just treated as a string and won't let me access any attributes.
ImportError! Could not load api or model class Users
Traceback (most recent call last):
File "filename.py", line XX, in <module>
AttributeError: 'str' object has no attribute 'get_current_user'
[1480] Failed to execute script filename
PyInstaller: 3.4
Python: 3.6.5
Windows: 7
Update:
It looks like smartsheet is trying to import the requests.packages.urllib3 library but this is failing. I've tride adding the directory to this file using:
pyi-makespec --paths=directory\requests\packages.py myapp.py
pyi-makespec --paths=directory\smartsheet\smartsheet.py myapp.py
but it's still failing.
Related
I'm beginner to both bash and python.
I'm working in Ubuntu env.
to be short, I've created a shell script 'format_data.sh' that runs python file 'proc_ko.py' within it.
#!/bin/bash
...
python path/to/python/file/proc_ko.py
...
And the python file 'proc_ko.py' imports a module called khaiii
from khaiii import KhaiiiApi
api = KhaiiiApi()
...
But when I try to execute 'format_data.sh', I get this import error from python file.
Traceback (most recent call last):
File "media/sf_projet/pe/pe/PROGRAMME/SCRIPTS/proc_ko.py", line 5, in
from khaiii import KhaiiiApi
ImportError: No module named khaiii
which doesn't occur when I execute python file independently.
Python file 'proc_ko.py' itself doesn't have any error and 'khaiii' is well installed.
so I don't understand why import error occurs only through the shell script.
If u need more details to figure out, I'll be happy to provide. Thanks in advance for help.
I have my own project with virtual environment. When I am trying to debug code everything executes flawlessly and I get the expected output, but when I am trying to run it with run code option from Code Runner extension I receive the error:
[Running] python -u "c:\Users\slikm\Pulpit\ytapi\yt_api.py" Traceback (most recent call last): File "c:\Users\slikm\Pulpit\ytapi\yt_api.py", line 2, in <module> from googleapiclient.discovery import build ModuleNotFoundError: No module named 'googleapiclient'
I have the library which the module is taken from installed on my venv. I read that the problem might be with the interpreter the extension uses, but I don't really know how to figure it out.
I created an application and bundled it to exe by pyinstaller, however after I tested the exe application, it responded an error message. It seems like my essential api module wasn't imported properly. Please advise, thanks!
ImportError! Could not load api or model class Sheets
Exception in Tkinter callback
Traceback (most recent call last):
File "tkinter\__init__.py", line 1883, in __call__
File "D:\Python Projects\Concept Number Generator\Concept Number Generator.py", line 12, in concept_num
my_sheet=smartsheet_client.Sheets.get_sheet(8743006875477892)
AttributeError: 'str' object has no attribute 'get_sheet'
Based on a search here in Stack Overflow, looks like others have run into this issue in the past. Try importing smartsheet.Sheets -- as described under the heading EDIT 2 in this question: including smartsheet sdk in a bundled app via pyinstaller.
I'm trying to create an exe out of a small Python Project. I have a main.py which imports packages from other subdirectories. After building the exe using pyinstaller when I run the executable I am facing import problems, its failing to identify the relative imports.
I tried modifying the .spec file but am unable to rectify the issue.
This is the current directory structure of my project
Link to project structure image
When I run the executable dist\cli\cli.exe it gives me this import error
Traceback (most recent call last):
File "cli.py", line 3, in <module>
from packages.__main__ import main
ImportError: No module named __main__
[5964] Failed to execute script cli
I have manually built python3.5.2 from sources on my ubuntu 15.10. The build process went well, but now when I execute below script
import subprocess
print(subprocess.run(["ls"]))
I receive following output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'run'
When I run same script on Windows (where I have installed python3.5.2 via installer) I receive expected output:
CompletedProcess(args='ls', returncode=0)
On my ubuntu machine subprocess.py is present in and it has "run" function defined.
I anticipated that python3.5.2 could look for subprocess.py in libs folder for 2.7 (preinstalled on ubuntu) but this is not the case.
What could be wrong with my installation?
Try
import subprocess
import sys
print(sys.executable)
print(subprocess)