Am I missing anything? - python-3.x

import pyaudio
robot_mount = __init__.cpython-311
robot_mount.say(robot_brain)
robot_mount.runAndWait()
NameError: name 'init' is not defined

Related

NameError: name 'LEFT_BUTTON' is not defined-Autopy ERROR

import autopy
autopy.mouse.click(LEFT_BUTTON)
OUTPUT:
NameError: name 'LEFT_BUTTON' is not defined
so I have tried:
import autopy
autopy.mouse.click(button=LEFT_BUTTON)
OUTPUT:
NameError: name 'LEFT_BUTTON' is not defined
LEFT_BUTTON is defined in autopy.mouse. Either import it:
import autopy
from autopy.mouse import LEFT_BUTTON
...
autopy.mouse.click(LEFT_BUTTON)
or reference it directly:
import autopy
...
autopy.mouse.click(autopy.mouse.LEFT_BUTTON)

How do I build a C extension as a submodule to a C extension main module with distutils?

I have two files, module.c and submodule.c.
I have the following code in setup.py:
from distutils.core import setup, Extension
module = Extension('module', sources = ['module.c'])
submodule = Extension('submodule', sources = ['submodule.c'])
setup (name = 'module',
version = '0.1',
description = 'a module that does things',
ext_modules = [module, submodule])
I build it as below:
$ DISTUTILS_DEBUG=1 python3 setup.py build
In the python shell, when I do the following:
>>> import module # works
>>> from module import submodule # this should work
...
ImportError: cannot import name 'submodule' from 'module' (/home/username/Projects/module/build/lib.linux-x86_64-3.8/module.cpython-38-x86_64-linux-gnu.so)
>>> import module.submodule # is this supposed to work?
...
ModuleNotFoundError: No module named 'module.submodule'; 'module' is not a package
>>> import submodule # This should not work
...
ImportError: dynamic module does not define module export function (PyInit_submodule)
Do note that in the last case (import submodule), my PyInit function was named PyInit_module_submodule(), which threw the ImportError. If I change it to PyInit_submodule(), then import submodule works.
I probably have a fundamental misunderstanding of how modules work in Python, so all help is appreciated.

NameError: name 'os_PathLike' is not defined

I wanted to load text into a numpy array. I have used the code below:
import numpy as np
import os
a = np.loadtxt(os.getcwd()+'abc.txt')
But I am getting an error as follows:
File "/Users/vivekchowdary/opt/anaconda3/lib/python3.7/site-packages/numpy/lib/npyio.py", line 965, in loadtxt
NameError: name 'os_PathLike' is not defined
Can anyone help me with what's going wrong with my code?

ImportError: cannot import name 'Collection'

While trying :
from typing import Collection
I get :
ImportError: cannot import name 'Collection'
In python 3.5 .

python3.5 : No module named 'twisted.enterprise'

I am using python3.5.2,there is a sentence in demo.py,as follow:
from twisted.enterprise import adbapi
There is an error when running:
from twisted.enterprise import adbapi
ImportError: No module named 'twisted.enterprise'
What should I do?

Resources