GVKun编程网logo

Visual Studio Code 找不到我的 python 文件 [Errno 2] 没有那个文件或目录(vscode找不到python编译器)

1

在这篇文章中,我们将带领您了解VisualStudioCode找不到我的python文件[Errno2]没有那个文件或目录的全貌,包括vscode找不到python编译器的相关情况。同时,我们还将为您

在这篇文章中,我们将带领您了解Visual Studio Code 找不到我的 python 文件 [Errno 2] 没有那个文件或目录的全貌,包括vscode找不到python编译器的相关情况。同时,我们还将为您介绍有关(OK) Spend Leap Day with TACO + VS Code (visual studio code) - Cordova、Celery Worker 错误:self.buffer = mmap.mmap(self.fd, self.size) FileNotFoundError:[Errno 2] 没有那个文件或目录、docker run -v : [Errno 2] 没有那个文件或目录、Dockerfile: 无法打开文件 './main.py': [Errno 2] 没有那个文件或目录的知识,以帮助您更好地理解这个主题。

本文目录一览:

Visual Studio Code 找不到我的 python 文件 [Errno 2] 没有那个文件或目录(vscode找不到python编译器)

Visual Studio Code 找不到我的 python 文件 [Errno 2] 没有那个文件或目录(vscode找不到python编译器)

如何解决Visual Studio Code 找不到我的 python 文件 [Errno 2] 没有那个文件或目录

我正在努力使用 Visual Studio Code python 编译器。每当我尝试运行代码时,它都会说

python: can''t open file ''c:\\Users\\User\\Desktop\\Programowasko\\Python\\Cybepunk encounter 
    calculator\\cyberpunk.py'': [Errno 2] No such file or directory

目前在那里编写的唯一代码是 print("Hello World")。还有任何其他最近有效的代码,现在都无效了。

解决方法

您是否尝试过使用没有空格的文件目录?例如Cybepunk_encounter_calculator 甚至用双引号括起来 "" 像 this

,

错误是由于空间。 也许以下可以帮到你

python "c:\\Users\\User\\Desktop\\Programowasko\\Python\\Cybepunk encounter calculator\\cyberpunk.py"
,

在VS Code中,当我们使用命令“python file.py”在其内部终端运行一个python文件时,需要我们去到可执行文件的父文件夹:(请检查文件的拼写和文件夹名称。)

enter image description here

另外,我们通常使用VS Code中“python”扩展提供的运行按钮,它会在终端自动执行运行命令。

(OK) Spend Leap Day with TACO + VS Code (visual studio code) - Cordova

(OK) Spend Leap Day with TACO + VS Code (visual studio code) - Cordova


http://taco.tools/articles/leap-day.html

15 Feb 2016 - by Linda

This year, we all have an extra day to spend doing whatever we want. So, why not take 15min to learn to build an iOS, Android and Windows app all at once?

This exericise introduces you to the core components of a Cordova app and how to create one in VS Code.

You in? Let’s go.

1. Setup

1.1 Install Visual Studio Code from the VS Code website, code.visualstudio.com.

VS Code is our lightweight, multi-screen code editor with the intellisense and debugging support of the Visual Studio IDE. This is the main tool we will use to create our Cordova project.

1.2 Install Apache Cordova, Ionic Framework, and the Tools for Apache Cordova CLI.

Enter into the Windows command prompt: npm install -g cordova ionic taco-cli

Or, enter into the Mac terminal: sudo npm install -g cordova ionic taco-cli

These are the three main tools we will use in VS Code.

  • Cordova is open source platform for building native mobile applications using HTML, CSS, JS.

  • Ionic is a front end framework for developing native-looking mobile apps built on top of Angular JS.

  • Tools for Apache Cordova is a product built at Microsoft that makes setting up and getting started really easy. It abstracts away the tool chain needed to test your app, and includes features like kits to make migrating to new versions of Cordova easy.

2. Get an App Going

2.1 Create your app: In the command promt, navigate to the directory in which you want your project to live, and type the command ionic start myLeapDay. This will create a basic Ionic app called myLeapDay using the default tabs template.

This walkthrough uses Ionic framework to create a basic, native-looking Cordova app.

2.2 Add and remove platforms using taco-cli

Enter your new Cordova project by typing cd myLeapDay into the command prompt and ls to explore the file structure of your project. If you type cd platforms, you will see that Ionic already has added iOS to the platforms folder, so you can build your Cordova app into an iOS app.

Now, add an Android app to your project by typing taco platform add android into the command prompt. That will mean that your Cordova project will now try to build into Android and iOS.

2.3 Play around!

Check out what your app looks like by deploying it in a browser. Navigate back to the root of your project, and type ionic serve into the command prompt to open myLeapYear in a lightweight emulator running in your web browser. (Unfortunately, you can only see the iOS version).

3. Turn this basic app into a collection of golf balls in VS Code

Now, we will use VS Code to start poking around inside your project. Open VS Code, then go to File > Open, and navigate to the folder where you can see myLeapDay. Click on the folder (but not into it!) and press open.

You can see in the screenshot that your project should have a platforms/android folder, which you added using taco-cli.

The app itself exists in the www/ folder. You can see all the parts of a traditional website in this folder:

  • css/ holds the an empty style.css, where you can add your own styling
  • img/ holds images and other site assets
  • js/ holds all the logic of the Angular JS project–essentially the core of the app
  • lib/ holds the Ionic framework files that acts as scaffolding for this project
  • templates/ holds the extra pages/html files shown in the app
  • index.html, the landing page and where the app begins

3.1 Download this zip of web assets from this post. Unzip the folder and drag all the images to the www/img/ folder of your project.

3.2 Modify the landing page of the app. In templates/tabs.html, you see all three tab categories shown on the naviagtion bar. The dashboard tab links to an ion-nav-view called tab-dash. In templates/tab-dash.html, replace the file with the one in the zip folder, leapday/tabs-dash.html. Deploy using ionic serve to see the change.

3.3 Add golf ball data. In js/services.js, there is test data called var chats. We are going to take advantage of the existing formatting to replace each chat with a golf ball, and add some new fields like category and dimensions. Replace the js/services.js with leapday/services.js.

Deploy to your browser again using ionic serve, and click on the chats tab to see the change. In particular, notice that the chats are now replaced with golf ball data. Tapping a golf ball takes you to the templates/chat-detail.html page, where you can see that the golf ball pictures are a bit skewed. On to the next step!

3.4 Fix formatting and using new fields.

Replace the file with the one in the zip folder, leapday/chat-detail.html. It replaces the line , allowing each golfball to have its own custom dimensions that we set in services.js.

Now, to customize the detail screen further, go to chat-detail.html and try adding the following line of code right above the <p> {{ chat.lastText }} </p> element: <h2>Pattern category: {{ chat.cat }} </h2>

4. Bonus: Deploy to a virtual Android device

Since you have been viewing the app in its iOS form, let’s take a look at how it looks in Android.

4.1 Navigate to the root of your project and enter taco install-reqs android into the command prompt. This will install the dependencies needed to build and deploy your Cordova app into the standard Android emulator (Android SDK and Java 7, update 55).

4.2 Open the Android SDK manager using the command android sdk (sudo android sdk on a Mac). Check the following boxes for Android 5.0.1 (API 21)

4.4 Enter android avd (sudo android avd on a Mac) to open the Andriod AVD manager, click “Create” and set up an Android virtual device. Be sure to specify an AVD name, Device, Target, and CPU/ABI

4.5 Return to the terminal, and at the root of your project, emulate using the command taco emulate android (or sudo taco emulate android)

5. Pat yourself on the back

You did it!! You’ve built your first Cordova app, viewed it on two different platforms, and are ready to hit the road. Please let us know how you enjoyed this brief tutorial, and what you’d like to see next.

And we would love to hear about how you enjoyed your time in VS Code. Send feedback by clicking on the smile in the bottom-right corner of the code editor.

Until next time,

Linda Zhong Program Manager | Tools for Apache Cordova
Microsoft Visual Studio
lizhong@



Celery Worker 错误:self.buffer = mmap.mmap(self.fd, self.size) FileNotFoundError:[Errno 2] 没有那个文件或目录

Celery Worker 错误:self.buffer = mmap.mmap(self.fd, self.size) FileNotFoundError:[Errno 2] 没有那个文件或目录

如何解决Celery Worker 错误:self.buffer = mmap.mmap(self.fd, self.size) FileNotFoundError:[Errno 2] 没有那个文件或目录?

我得到 self.buffer = mmap.mmap(self.fd,self.size) FileNotFoundError: [Errno 2] 在 Windows 上用 docker 运行 celery 时没有这样的文件或目录错误。它在 mac 上完美运行。

dvu-celeryworker    | [2021-03-26 11:08:20,286: CRITICAL/MainProcess] Unrecoverable error: FileNotFoundError(2,''No such file or directory'')
dvu-celeryworker    | Traceback (most recent call last):
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/celery/worker/worker.py",line 208,in start
dvu-celeryworker    |     self.blueprint.start(self)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/celery/bootsteps.py",line 119,in start
dvu-celeryworker    |     step.start(parent)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/celery/bootsteps.py",line 369,in start
dvu-celeryworker    |     return self.obj.start()
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/celery/concurrency/base.py",line 132,in start
dvu-celeryworker    |     self.on_start()
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/celery/concurrency/prefork.py",line 111,in on_start
dvu-celeryworker    |     P = self._pool = Pool(processes=self.limit,dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/celery/concurrency/asynpool.py",line 486,in __init__
dvu-celeryworker    |     super(AsynPool,self).__init__(processes,*args,**kwargs)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/pool.py",line 1046,in __init__
dvu-celeryworker    |     self._create_worker_process(i)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/celery/concurrency/asynpool.py",line 503,in _create_worker_process
dvu-celeryworker    |     return super(AsynPool,self)._create_worker_process(i)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/pool.py",line 1142,in _create_worker_process
dvu-celeryworker    |     on_ready_counter = self._ctx.Value(''i'')
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/context.py",line 181,in Value
dvu-celeryworker    |     return Value(typecode_or_type,lock=lock,dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/sharedctypes.py",line 78,in Value
dvu-celeryworker    |     obj = RawValue(typecode_or_type,*args)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/sharedctypes.py",line 46,in RawValue
dvu-celeryworker    |     obj = _new_value(type_)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/sharedctypes.py",line 37,in _new_value
dvu-celeryworker    |     wrapper = heap.BufferWrapper(size)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/heap.py",line 274,in __init__
dvu-celeryworker    |     block = BufferWrapper._heap.malloc(size)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/heap.py",line 255,in malloc
dvu-celeryworker    |     (arena,start,stop) = self._malloc(size)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/heap.py",line 152,in _malloc
dvu-celeryworker    |     arena = Arena(length)
dvu-celeryworker    |   File "/usr/local/lib/python3.8/site-packages/billiard/heap.py",line 104,in __init__
dvu-celeryworker    |     self.buffer = mmap.mmap(self.fd,self.size)
dvu-celeryworker    | FileNotFoundError: [Errno 2] No such file or directory

请帮忙。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

docker run -v : [Errno 2] 没有那个文件或目录

docker run -v : [Errno 2] 没有那个文件或目录

如何解决docker run -v : [Errno 2] 没有那个文件或目录

我正在尝试跑步

  1. docker run --rm -v ~/.aws:/root/.aws \\
  2. -v $(pwd)/scripts:/root/scripts \\
  3. --link "${DYNAMO_CONTAINER}:localhost" \\
  4. amazon/aws-cli dynamodb batch-write-item \\
  5. --request-items file:///root/scripts/sampledata.json \\
  6. --endpoint-url http://localhost:8000

我得到的错误是

  1. Error parsing parameter ''--request-items'': Unable to load paramfile file:///root/scripts/sampledata.json: [Errno 2] No such file or directory: ''/root/scripts/sampledata.json''

我也试过

  1. docker run --rm -v ~/.aws:/root/.aws \\
  2. -v $(pwd)/scripts:/root \\
  3. --link "${DYNAMO_CONTAINER}:localhost" \\
  4. amazon/aws-cli dynamodb batch-write-item \\
  5. --request-items file:///root/scripts/sampledata.json \\
  6. --endpoint-url http://localhost:8000

  1. docker run --rm -v ~/.aws:/root/.aws \\
  2. -v $(pwd)/scripts:/root \\
  3. --link "${DYNAMO_CONTAINER}:localhost" \\
  4. amazon/aws-cli dynamodb batch-write-item \\
  5. --request-items file:///root/sampledata.json \\
  6. --endpoint-url http://localhost:8000

在最后一个中,虽然路径不同,但我仍然收到 No such file... 错误。

主机scripts目录的结构是

  1. scripts
  2. ├── sampledata.json
  3. └── other.sh

我做错了什么...?

Dockerfile: 无法打开文件 './main.py': [Errno 2] 没有那个文件或目录

Dockerfile: 无法打开文件 './main.py': [Errno 2] 没有那个文件或目录

如何解决Dockerfile: 无法打开文件 ''./main.py'': [Errno 2] 没有那个文件或目录

我收到此错误:python: can''t open file ''/src/main.py'': [Errno 2] No such file or directory 当我尝试使用使用以下 docker 文件构建的映像运行容器时:

  1. FROM python:3.9-slim AS compile
  2. RUN python -m venv /opt/venv
  3. ENV PATH="/opt/venv/bin:$PATH"
  4. workdir /my-app
  5. copY requirements.txt .
  6. RUN pip install -r requirements.txt
  7. ADD src/ ./src
  8. RUN pip install .
  9. FROM python:3.9-slim AS build
  10. copY --from=compile/opt/venv /opt/venv
  11. ENV PATH="/opt/venv/bin:$PATH"
  12. CMD ["python","/src/main.py"]

我也试过这个,但它仍然给我同样类型的关于找不到 main.py 的错误:我试过 ./src/main/py、/src/main.py、/src/main.py, ./main.py.我尝试了一切,我开始怀疑错误出在其他地方

解决方法

/src/main.py 是系统根目录的绝对路径。

为了与您当前的目录相关,请使用 ./src/main.py

,

我将简化您的 docker 文件如下:

  1. # base image
  2. FROM amazonlinux:1
  3. # Set the working directory
  4. WORKDIR /app
  5. # Copy the current directory contents into the container at /app
  6. COPY . /app
  7. # Install requirements
  8. RUN pip install -r requirements.txt
  9. # Define environment variable
  10. ENV PYTHONPATH "${PYTHONPATH}:/app"
  11. # Run main.py when the container launches
  12. ENTRYPOINT ["python","-u","src/main.py"]
,

问题是您有多阶段构建(2x FROM),而您只将它们添加到第一阶段。

  1. FROM python:3.9-slim AS compile
  2. [..]
  3. ADD src/ ./src
  4. ADD setup.py .
  5. RUN pip install .
  6. FROM python:3.9-slim AS build
  7. [..]

您可以在 2. 阶段使用第二个 COPY --from= 语句解决此问题。 另外你的 CMD 是错误的。要么给它完整路径,要么用 .目录/文件名(/my-app/src/main.py./src/main.pysrc/main.py)。

  1. FROM python:3.9-slim AS compile
  2. RUN python -m venv /opt/venv
  3. ENV PATH="/opt/venv/bin:$PATH"
  4. WORKDIR /my-app
  5. COPY requirements.txt .
  6. RUN pip install -r requirements.txt
  7. ADD src/ ./src
  8. ADD setup.py .
  9. RUN pip install .
  10. FROM python:3.9-slim AS build
  11. COPY --from=compile/opt/venv /opt/venv
  12. COPY --from=compile/my-app /my-app # ADDED
  13. WORKDIR /my-app # ADDED
  14. ENV PATH="/opt/venv/bin:$PATH"
  15. CMD ["python","/my-app/src/main.py"] # FIXED

最后,您只在丢弃的阶段设置工作目录,但这仅在您没有为 cmd 提供完整路径或需要特定工作目录时才相关。

今天关于Visual Studio Code 找不到我的 python 文件 [Errno 2] 没有那个文件或目录vscode找不到python编译器的分享就到这里,希望大家有所收获,若想了解更多关于(OK) Spend Leap Day with TACO + VS Code (visual studio code) - Cordova、Celery Worker 错误:self.buffer = mmap.mmap(self.fd, self.size) FileNotFoundError:[Errno 2] 没有那个文件或目录、docker run -v : [Errno 2] 没有那个文件或目录、Dockerfile: 无法打开文件 './main.py': [Errno 2] 没有那个文件或目录等相关知识,可以在本站进行查询。

本文标签:

上一篇在 Python 中同时等待多个阻塞调用(python 多线程 等待)

下一篇应用不起作用,列表仅显示 Python 中的 1 个项目和 Geopy城市