我有一个简短的问题。我尝试用以下命令导入'os.listdir‘
import os.listdir
但是,它向我显示了如下所示的错误。
Exception has occurred: ModuleNotFoundError
No module named 'os.listdir'; 'os' is not a package
File "/Users/chanwooahn/Google Drive/Projects/The Economist/main.py", line 1, in
<module>import
在OS上为Python3.3尝试wxPython凤凰(我不确定Python3phoix支持哪个版本,我强制-安装它)。
>>> import wx
>>> wx.App()
This program needs access to the screen. Please run with a
Framework build of python, and only when you are logged in
on the main display of your Mac.
现在我读到了,它说wxPython在虚拟环境中存在一个问题,并通过这个脚本提供了一个修复
我有一个python包,它依赖于另外两个python包,我不想将它们作为鸡蛋或轮子分发。
我已经设置了我的git模块文件来将这些包拉下来,但是,现在我想为主包创建我的setup.py脚本,这样它也可以为两个子模块运行setup.py脚本。
我可以通过将以下内容添加到主setup.py脚本中,从而以一种黑客的方式完成这一任务:
# run the setup for the sub modules.
from subprocess import Popen
import os
import sys
dir1 = os.path.join(os.path.dirname(os.path.real
尝试在windows10上的Python 3.6版本上运行pip安装os模块。搜索导致我以管理员身份运行,尝试更新pip,使用不同的缓存目录运行,以便它下载新的tarball,并更新setuptools。什么都不走运。对我来说非常奇怪的是文件名中的双反斜杠。当涉及到python架构时,我非常生疏。有一件事可能相关,也可能不相关,那就是这是一台替换PC,我试图从我的Win7 PC迁移数据。但这可能是转移视线。不管怎样,这是输出。感谢您的帮助。谢谢!
c:\Python36>pip install os
Collecting os
Using cached os-0.5.tar.gz
我第一次尝试使用pyCallGraph来分析我的代码。我使用的是Windows 7,Python 3.6
我用过
pip install pyCallGraph
pip install graphviz
已成功完成。现在,当我尝试使用python脚本中的命令时,我得到以下错误:
PyCallGraphException: The command "dot" is required to be in your path.
所以好吧,我知道有些东西不在我的“路径”上,不管是什么。我不能使用给出的传统答案(例如,转到窗口、属性、高级...)因为我在我的计算机上没有管理员权限。
所以我
在导入python时安装了熊猫之后,我得到了以下错误:
File "<stdin>", line 1, in <module>
File "C:\Users\ss\AppData\Local\Programs\Python\Python38\lib\site-packages\pandas\__init__.py", line 11, in <module>
__import__(dependency)
File "C:\Users\ss\AppData\Local\Programs\Python\P
当我尝试使用pip命令时,stdout中出现了一些恼人的消息:
~# pip -V
Platform: linu
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
~# pip install
Platform: linu
You must give at least one requirement to install (see "pip help install")
Python命令正常工作。
OS - Ubuntu 14.04
我试着重新安装pip和所有依赖项,但是没有帮助。
那是什么,从哪里来的?
这是读取excel中数据的代码。
import os
import pandas as pd #pandas library is to work with dataframes
os.chdir("C:\Education\Study Materials\Python for Data science\Data Sets")
data_xlsx=pd.read_excel("Iris_data_sample.xlsx", sheet_name="Iris_data")
错误: ImportError:缺少可选的依赖项'xlrd‘。安装
下面的python脚本应该打印所需的名称
脚本读取包含functions.py函数的get_names
more names.py
import os
import sys
script_dir = os.path.dirname(os.path.abspath(__file__))
python_files_dir = os.path.join(script_dir, 'python_files')
sys.path.append(python_files_dir)
from functions import *
# name
Name = get_names()
有没有人能告诉我为什么会有这种行为:
C:\...>dir C:\Windows\System32\drivers\subdir\0xDEADBEEF.008
Volume in drive C is Win7HPx64
Volume Serial Number is 04BF-EE2E
Directory of C:\Windows\System32\drivers\subdir\0xDEADBEEF.008
08/11/2011 04:21 PM <DIR> .
08/11/2011 04:21 PM <DIR>
我刚刚发现了熊猫的情况,现在就安装了buy,我的循环迭代文件的行为很奇怪。下面是一个对我来说有问题的极小的例子:
#!/usr/bin/env python
import os
PATH=os.environ['HOME']+"/scripts/"
for path_, dir_names, file_names in os.walk(PATH):
for name in file_names:
print(path_+name)
由于文件夹中只有一个singe文件(即此脚本),输出结果与预期的一样:
/home/scripts/parser.p
我尝试使用Python的os,手动将变量输入终端,并使用.env文件设置我的环境变量,但总是
raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Python
# env.py
import os
os.environ['SECRET_KEY'] = '<my secret key>