简体   繁体   English

如何将我的 Python 代码(其中有 pip 模块)发送给没有安装 Python 的朋友?

[英]How can I send my Python Code (Which has pip modules) to a friend who doesn't have Python installed?

I wrote a Text Grammar Checker in Python for a friend of mine.我为我的一个朋友在 Python 中写了一个文本语法检查器。 Since he doesn't have Python installed, I searched for ways to get it to him, but there was always a catch.由于他没有安装 Python,我想方设法将它交给他,但总是有一个问题。 Compiling it to a.exe file doesn't work because it uses a module called pyspellchecker which uses a deprecated module called indexer (At least I think that's why it doesn't work).将其编译为 .exe 文件不起作用,因为它使用了一个名为pyspellchecker的模块,该模块使用了一个已弃用的名为indexer的模块(至少我认为这就是它不起作用的原因)。 Another option would be to use an online IDE, but I could find none that could run my code using the modules it uses.另一种选择是使用在线 IDE,但我找不到可以使用它使用的模块运行我的代码的工具。 Is there any good option left for me or is this a lost cause?有没有什么好的选择留给我,或者这是一个失败的原因? I'd really appreciate any help我真的很感激任何帮助

Here's the source code if required: https://gist.github.com/AaryanGamer/093385d3df463282117edf2021b7cbc2如果需要,这是源代码: https://gist.github.com/AaryanGamer/093385d3df463282117edf2021b7cbc2

  • Docker is the 1st option: Docker installation required for your friend. Docker 是第一个选项:您的朋友需要安装 Docker。
  • Deploy your script as simple web service is the 2nd option: Your friend need just Browser.将您的脚本部署为简单的 web 服务是第二个选项:您的朋友只需要浏览器。
  • The third option that I found convenient for your use case is using PyInstaller , That freezes (packages) Python application into stand-alone executable app.我发现对您的用例方便的第三个选项是使用PyInstaller ,它将 Python 应用程序冻结(打包)为独立的可执行应用程序。

Documentation link https://www.pyinstaller.org/文档链接https://www.pyinstaller.org/

My first instinct would be to use a virtual environment ( venv ), and send your friend the whole folder structure.我的第一直觉是使用虚拟环境( venv ),并将整个文件夹结构发送给您的朋友。 I searched for "venv portable", and the first result - https://aarongorka.com/blog/portable-virtualenv/ - may be what you're looking for if you're both in a Linux environment.我搜索了“venv 便携”,第一个结果 - https://aarongorka.com/blog/portable-virtualenv/ - 如果你们都在 Linux 环境中,可能就是您正在寻找的结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果我想在另一台没有安装 python 的机器上运行包含模块的 python 代码,我可以这样做吗? - If I want to run python code that includes modules on another machine that doesn't have python installed, can I do this? 朋友没有安装 Python 模块是否有“解决方法”? - Friend doesn't has Python module installed is there a "workaround"? 我已经在pip中上传了一个Python包,然后pip安装了这个包,但是我在Python Interpreter中无法导入这个包 - I have uploaded a Python package in pip, then pip installed this package, but I can't import this package in Python Interpreter 如何在没有必需的外部库模块的其他系统上运行Python代码? - How can I run my Python code on other system which doesn't have the required external library module? 如何在我的python脚本中包含pip安装的模块? - How can I include a pip installed module with my python script? 如何使用 Python 3.7 或更高版本查看 Jupyter Lab 中所有已安装的 Python 模块(如 pip freeze)? - How can I see all installed Python modules in Jupyter Lab (like pip freeze) with Python 3.7 or newer? 使用 Pip 在 Python 3.8 中成功安装模块但我无法导入它们? - Successfully installed modules in Python 3.8 using Pip but I can't import them? 当我的计算机上有 Python 2、Python 3 和 Anaconda 时,如何控制将包安装到哪个 Python 发行版? - How can I control which Python distribution to pip install a package to when I have Python 2, Python 3, and Anaconda on my computer? pip 对我不起作用(我安装了 python 3.9.7)(Windows) - pip doesn't work for me (I have python 3.9.7 installed) (Windows) 我在Mac上安装了python 2.7和3.6。 如何找到与Python3相关的pip版本? - I have python 2.7 and 3.6 installed on my mac. How to find the version of pip associated with Python3?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM