简体   繁体   English

在 PyCharm 终端外使用 PyCharm 解释器

[英]Use PyCharm interpreter outside of PyCharm terminal

I'm testing some library integration and I wanted to run it outside of PyCharm's terminal.我正在测试一些库集成,我想在 PyCharm 的终端之外运行它。 I tried the ordinary python./client.py after moving to the script's directory, but the response says it cannot find my modules.移动到脚本目录后,我尝试了普通的python./client.py ,但响应说找不到我的模块。 I tried directly calling the interpreter in the project's 'venv' folder ./venv/bin/python./core/client.py , but again it tells me it cannot find the module.我尝试直接在项目的“venv”文件夹中调用解释器./venv/bin/python./core/client.py ,但它再次告诉我它找不到模块。 How can I use this interpreter outside of the PyCharm IDE?如何在 PyCharm IDE 之外使用此解释器?

If you need it, the project's file system looks like this:如果需要,项目的文件系统如下所示:

- Sparro
    - core
        - __init__.py
        - client.py
        - packagers.py
        - queue_manager.py
        - server.py
        - utils.py
    - strategy
        - pairs.py
    - venv
        - bin
            - ...
            - python3
        - include
        - python3.8
            - site-packages

In your pycharm project folder, if your on windows open a cmd and run the command .\venv\Scripts\activate .在您的 pycharm 项目文件夹中,如果您在 windows 上打开 cmd 并运行命令.\venv\Scripts\activate If your on mac/linux open a terminal and run source venv/bin/activate .如果你在 mac/linux 上打开一个终端并运行source venv/bin/activate This will put you in your virtual environment for that project and your scripts will be able to use the modules that you installed.这将使您进入该项目的虚拟环境,并且您的脚本将能够使用您安装的模块。

For more info on virtual environments you can check out the documentation here: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/有关虚拟环境的更多信息,您可以在此处查看文档: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM