在Mac上工作时,我的桌面上有单独的.py文件,在终端中输入以下内容时,这些文件会打开并运行良好:
cd desktop
python3 filename.py
现在,我在桌面上创建了一个名为Python的文件夹,以更好地存储这些文件,但无论我尝试了什么,我似乎都无法访问它。我试过以下几种方法
cd desktop/Python (file or directory doesn't exist)
cd desktop/Python python3 filename.py (file or directory doesn't exist)
有什么想法吗?
在使用我的Python解释器设置PyDev时,我选择了"Auto Config“来打开一个目录列表。然后按OK,并得到一条错误消息:
Error: Python stdlib not found or stdlib found without .py files.
显然,它正在寻找像threading.py和traceback.py这样的文件(不仅仅是它们的可执行文件)。
但是,我能够在/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7中找到这两个文件
"Auto Config“文件夹列表中的一个文件夹
下面是文本文件textfile.txt的目录结构,它是位于根目录中的python脚本readtext.py的文本文件的文件路径。python文件从shell中运行。python文件中的代码如下。
with open(<file_path>,'r') as infile:
print infile.read()
目录结构
/
root
readtext.py
home
user1
textfile.txt
我想在我的工作区中设置一个python3虚拟环境。我有两个版本的python,安装在下面的路径中:C:\Python\Python27\python2.exe C:\Python\Python38\python3.exe。我已经在powershell终端上检查了它们是否正确安装。
我尝试了python3 -m venv .venv命令。它创建了一个.venv文件夹,但我得到以下错误消息:"Error: [Win Error2] The system cannot find the file specified。我的IDE是Visual Studio Code 1.39.2
此外,还将
以下是该文件夹的结构: - python
- python study
- study.py
- a.txt study.py中的代码是: import os
if(os.path.exists("a.txt")):
print("YES") # my real code is not this
else:
print("NO") 通常我会以pycharm项目的形式打开python study文件夹,如下所示: ? 结果就是YES。 但今天我无意中打开了python文件夹(而不是python study)作
因此,我需要运行这个run.sh文件,并且无法使用windows默认的CMD。因此,我安装了Cygwin64终端,它自动读取文件,但在读取结束时,它发送了一个错误:
$ /cygdrive/c/Python27/Scripts/./run.sh
Starting scraper
Scrape complete, checking movies with imdb
C:\python27\python.exe: can't open file 'check_imdb.py': [Errno 2] No such file or directory
内部run.sh
#!/
我基本上是在visual上使用python (初学者),并继续将python文件导入另一个python文件。我正在执行一项任务,它有3个文件a、b和test_a,同时在文件'a‘中创建一个函数,并将该文件导入test_a以测试一个函数,但没有得到答案。
我尝试使用这一行导入'test_a‘中的文件'a’,但无法导入。
from a import *
知道如何将整个文件导入另一个文件吗?