我不明白为什么Python在这种情况下会抛出异常。我尝试从全局安装的包中导入,而有一个前缀与包名相同的文件。我遗漏了什么?
$ touch fabric.py
$ python2
...
>>> from fabric.api import run
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named api
我正在尝试导入fabric.api并出现问题。我使用pip安装了fabric,当我在解释器中运行import fabric时,它可以运行fin。
但是,当我执行from fabric.api import *时,它会发出一个错误,说“没有模块名为api”。我正在使用Python2.7。我在这里错过了什么?
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyri
我试图在'Azure Notebooks'中执行一个脚本,以便使用'Azure-storage-blob'将blob上传到Azure Data lake Gen 2,但由于无法使用import 'BlobServiceClient',所以无法执行。我安装了最新版本的'Azure-storage-blob' - 12.9.0。但在进口'BlobServiceClient'方面仍面临问题
下面是代码
import azure.storage.blob
from azure.storage.blob import blo
我对下面的repl交互感到困惑:
In [7]: import os
In [8]: os.sys
Out[8]: <module 'sys' (built-in)>
In [9]: os.sys.stderr
Out[9]: <_io.TextIOWrapper name='<stderr>' mode='w' encoding='UTF-8'>
In [10]: from os.sys import stderr
------------------------------------
刚安装了fabric,尝试使用在不同服务器上工作的相同的fabfile,得到以下错误:
Traceback (most recent call last):
File "/var/lib/python-support/python2.6/fabric.py", line 1211, in main
load(fabfile, fail='warn')
File "/var/lib/python-support/python2.6/fabric.py", line 467, in load
execfile(filename
我正在尝试从pyside的示例构建示例widgetbinding。我成功地构建了模块pyd,但在构建pyd之后无法导入该模块。我也尝试了我自己的C++ Qt库,得到了同样的错误。
我使用cmake构建绑定模块:
cmake -B ./build -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release
cd build
nmake
nmake install
cd .. # back to the directory my pyd installed
ipython # start testing the importing
In [1]
我有一个非常奇怪的错误,在从AWS的主目录启动的Python中得到导入错误,而当我将cd导入到另一个目录并在那里启动Python时,相同的包会很好地导入。
EMR安装了Python2.7。请让我知道我能提供什么额外的信息。这个问题快把我逼疯了!
$ python
Python 2.7.16 (default, Mar 18 2019, 18:38:44)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "lic
我正在尝试导入另一个文件夹中的包,它在python3.4中运行得非常好。例如:文件存在于库文件夹中。
user> python
Python 3.4.1 (default, Nov 12 2014, 13:34:29)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from libraries.control
我已经安装了paramiko,当我在python中导入它时,它正常工作,但是运行fabric时会出现以下错误:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/fabric/network.py", line 24, in <module>
import paramiko as ssh
ImportError: No module named paramiko
我能做什么?
我有两个文件夹在我的PYTHONPATH。
这两个文件夹都有子文件夹“test”。
当尝试从第二个“test”子文件夹导入时,我得到了ImportError。
如何解决这个问题呢?
PYTHONPATH = /dir1:/dir2
ll /dir1
drwxrwxr-x 3 me me 4096 tests
ll /dir1/tests
-rw-rw-r-- 1 me me 0 __init__.py
ll /dir2
drwxrwxr-x 3 me me 4096 tests
ll /dir2/tests
-rw-rw-r-- 3 me me 4096 myTest
-
我有一个virtualenv,在这个virtualenv中,我尝试运行一个fabfile。
fabfile的开头是这样的:
import httlib2
当我尝试执行
fab --list
要获取可用任务的列表,我会获取:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/fabric/main.py", line 658, in main
docs
from theano.tensor import stacklists, scalars, matrices
from theano import function
a, b, c, d = scalars('abcd')
X = stacklists([[a, b], [c, d]])
f = function([a, b, c, d], X)
f(1, 2, 3, 4)
这是我的程序。我在跟踪error.can,有人来帮忙吗
ImportError Traceback (most recent cal
我的电脑里安装了蟒蛇。我已经安装了tensorflow的所有模块。我正在尝试从jupyter笔记本中导入tensorflow,但是我得到了以下错误。
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0xb but this version of
我有两个子文件夹A和B。我正在尝试从同级A导入包。
我在每个子文件夹和根项目中都有__init__.py。
然而,尽管文件存在于文件夹A中,但从我在文件夹B中执行的文件中,我得到了以下错误
Traceback (most recent call last):
File "/home/ubuntu/workspace/cloud-devops/B/ufw_firewall.py", line 5, in <module>
from getparms import *
ImportError: No module named getparms
如何导入我的包
我在进程中间遇到了"ImportError:无法导入名称'isMappingType‘“来为Django项目部署fabfile。
1.这是我的fabfile.py的结构
from __future__ import with_statement
from fabric.api import *
from fabric.contrib.console import confirm
from fabric.contrib.files import append, exists, sed
env.hosts = ["127.0.0.1"]
env.user = r
我看了一个用Python编写的关于OpenCV的教程。当我试图导入一个类时,我会得到一个错误。错误在下面。
Traceback (most recent call last):
File "webstreaming.py", line 1, in <module>
from pyimagesearch.motion_detection import SingleMotionDetector
ImportError: cannot import name 'SingleMotionDetector' from 'pyimagese
尽管安装了babel,但我还是对Flask和Babel不能工作感到相当好笑和恼火。
pip install babel
pip install Flask-Babel
Traceback (most recent call last):
File "run.py", line 8, in <module>
from app import app
File "/home/ubuntu/workspace//dashboard/app/__init__.py", line 3, in <module>
from fla
我是Python的新手。我试着运行这段代码,但是我得到了一条关于ImportError的错误消息:没有名为“HTMLParser”的模块。我使用的是Python 3.x。这不起作用有什么原因吗?
#Import the HTMLParser model
from HTMLParser import HTMLParser
#Create a subclass and override the handler methods
class MyHTMLParser(HTMLParser):
#Function to handle the processing of HTML comments
我曾尝试将sys.path.append()与os.getcwd()结合使用,但它没有起作用。
该源来自,我下载并解压缩它们如下:
alvas@ubi:~/test$ wget https://github.com/alvations/DLTK/archive/master.zip
alvas@ubi:~/test$ tar xvzf master.zip
alvas@ubi:~/test$ cd DLTK-master/; ls
dltk
alvas@ubi:~/test/DLTK-master$ cd dltk/; ls
tokenize
alvas@ubi:~/test/DLTK-m
我试图导入子进程。然而,我甚至无法导入子进程。
目前,我的文件(throwaway.py)只包含一行:
import subprocess
但是它返回错误:
Traceback (most recent call last):
File "throwaway.py", line 1, in <module>
import subprocess
ImportError: bad magic number in 'subprocess': b'\x03\xf3\r\n'
Error in sys.excepthook:
Tra