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)
Related
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.
Something in my setup of my shell causes arbitrary strings like "krmpfl" or "u45g5svtJ7" to create a Python error:
$> krmpfl
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 28, in <module>
from CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
from CommandNotFound.db.db import SqliteDatabase
File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
I would expect bash (and not python!) to throw an error of the kind "Unknown command krmpfl. Did you mean...", but any non-recognized command is for some reason passed to python. I am confused.
Does anyone have an idea on how to debug this or how to move forward? I've tried type krmpfl but this (correctly) echoes bash: type: krmpfl: not found
My setup:
Win10 using Ubuntu 18.04 within WSL
ConEmu as a console
Bash-it
Python 3.8
Click (python package) installed to simplify creating commands
If your current shell function defines a function named command_not_found_handle, bash runs that for a non-existent command rather than immediately failing with a "command not found" error. In your case, that function exists and calls /usr/lib/command-not-found, which appears to be a Python script that tries to download (or at least suggest you download) a package with apt_pkg, but you don't have that Python module installed, which leads to the Python exception.
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.
I have a simple module called mini. It can be imported in either python interactive interpreter or a python .py script. The module is a C extension based so I want to debug it in gdb (version > 7). I learned that gdb has python command to interpret python command or script like:
(gdb) python import mini
However, it failed to import the module by saying:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named mini
I guess it might be the environment setting with either my gdb setting or my linux searching path setting. What will be the possible reason of this problem? Thanks.
I am trying to execute "import android" command on the python shell. It gives error like this :
>>> **import android**
Traceback (most recent call last):
File "<pyshell#11>", line 1, in <module>
import android
File ".\android.py", line 51
print result['error']
^
I'm having python 3.3.2 installed on the PC (windows 7) and have android.py (SL4A) available in the python directory on my system and the system path also contains python.
Plz help in resolving this error.
Print changed from a statement to a function on Python 3. And the module(android) you're trying to import is written for Python 2.
You should either use a Python 2 interpreter, or find(or make) that module compatible with Python 3.