简体   繁体   中英

Program works when I run it on the IDE (Pycharm) but not when I run it on the terminal?

So I've written a desktop application on Python. It works fine when I run it by manually clicking 'Run main' through the IDE but when I do: python main.py the terminal does find the program but doesn't recognize the libaries.

I've tried installing the libaries/modules a couple of times on the terminal and it says i've installed them but i guess not. These are the libaries/modules that refuses to work.

from iconsdk.icon_service import IconService
from iconsdk.providers.http_provider import HTTPProvider

The output on the console (when I run 'python main.py') is this:

Traceback (most recent call last): File "main.py", line 1, in import gui File "/Users/adam/PycharmProjects/igotmemed/gui.py", line 9, in import blockgen File "/Users/adam/PycharmProjects/igotmemed/blockgen.py", line 2, in from iconsdk.providers.http_provider import HTTPProvider File "/Users/adam/miniconda3/lib/python3.7/site-packages/iconsdk/providers/http_provider.py", line 17, in import requests File "/Users/adam/miniconda3/lib/python3.7/site-packages/requests/ init .py", line 43, in import urllib3 File "/Users/adam/miniconda3/lib/python3.7/site-packages/urllib3/ init .py", line 8, in from .connectionpool import ( File "/Users/adam/miniconda3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 26, in from .packages.ssl_match_hostname import CertificateError ImportError: cannot import name 'CertificateError' from 'urllib3.packages.ssl_match_hostname' (unknown location)

Something significant to note is 'CertificateError'.

Did you create your project with PyCharm? Because I think it also creates a virtual environment by default. Here is how the new project screen looks like: 在此处输入图片说明

Checking the location of your virtual env:

In the Settings/Preferences dialog (Ctrl+Alt+S), select Project: | Project Interpreter.

There you should be able to see the location of the project's virtual environment.

Then simply activate that virtual environment from your terminal and run your script.

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