简体   繁体   中英

PYTHON: How do you run your programs from the terminal?

I wrote this program that controls your computer to collect data from a website in the PyCharm IDE with python 3.7. In my program I imported different libraries like pyautogui.

import pyautogui, time, re, os


def process():
    # The rest of the code

Auto is the project name I have all the files in. I want to run the program from my terminal without having to run it from PyCharm but I'm getting these errors in it:

    laptop:auto user$ python ./test.py
    Traceback (most recent call last):
        File "./test.py", line 1, in <module>
            import pyautogui, time, re, os
    ImportError: No module named pyautogui

I downloaded Pyautogui onto my laptop using pip but I don't know how to make it so that the terminal can use the library. Any suggestions on what I should do to solve this problem?

I think you having ImportError for import pyautogui try this,

import error for pyautogui

So, I basically was trying to run it in a python 2.X shell. I installed Pyautogui with pip3 install pyautogui inside my project folder and ran the program using the command python3 ./test.py to run it on a python 3.X shell. Everything works perfectly now! Thank y'all for the help :D

While working in PyCharm IDE, By Default it creates a Virtual Env (venv) . If you had installed packages in your PyCharm IDE. It's scope is limited to that Virtual Environment.

Solution:

While running on CMD terminal or any other linux terminal you've to PIP install every package as it'll be then a Global package.

Hope this helps let me know if you have any questions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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