0

But they work just fine in IDLE. For example,

import time

time.asctime()

works fine in IDLE, but is not working in Pycharm.

I have tried changing the interpreter but still doesn't work. Other packages that I installed myself from cmd like numpy are working fine.

Any help will be appreciated

EDIT : When I add the package time by pressing + in the interpreter settings, it says

ERROR: Could not find a version that satisfies the requirement time

Kalana
  • 5,631
  • 7
  • 30
  • 51
  • you are probably using the wrong python version go check in settings – youssef jallouli Apr 17 '21 at 12:39
  • Does this answer your question? [PIP Cryptography Failing to Install](https://stackoverflow.com/questions/59143740/pip-cryptography-failing-to-install) – Kalana Apr 17 '21 at 12:42
  • @Kalana Nope, it doesn't. I get an error. Edited my post. – OvermanZarathustra Apr 17 '21 at 12:47
  • You probably don't have an interpreter selected. `time` is a standard library and you shouldn't have this error if the interpreter is normal. – A random coder Apr 17 '21 at 12:53
  • 3
    I think you are attempting to add a package that already exists in the standard library. You don't need to add this. Attempting to add this is probably going to try to pull it from pypi. But malicious package squatters will publish malicious packages to pypi with the same name as std lib & I'm guessing pycharm is trying to protect you from that. – MatthewMartin Apr 17 '21 at 12:53
  • @Arandomcoder you are right. I shouldn't have to add it because it is standard library. I just tried to anyway because its not working in Pycharm. – OvermanZarathustra Apr 17 '21 at 12:56
  • I agree with @MatthewMartin. `time` library already comes with Pycharm. There is no need to install it separately. Setup your interpreter and venv. – Kalana Apr 17 '21 at 12:56
  • @MatthewMartin yeah you are right. But standard library is not working for me in Pycharm, so I tried adding it anyway – OvermanZarathustra Apr 17 '21 at 12:57
  • 1
    They you must be getting an additional error somewhere. My guess is that you need to configure the interpretor: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html#interpreter You will be doing this a lot working with pycharm. Unlike other languages the interpretor can be anywhere on disk. Pycharm can't guess for you. – MatthewMartin Apr 17 '21 at 12:59
  • 1
    You say *is not working in PyCharm*. In exactly what way does it not work? What error message to do you get? If you get no error message, and you have shown us *your whole program* then your problem is that you are expecting `time.asctime()` on its own to produce output the way it does in IDLE. But to get the same effect in a program that PyCharm runs, you need something like `print(time.asctime())`. To get PyCharm to do what IDLE does in this case, you need to ask PyCharm to open a Python console. – BoarGules Apr 17 '21 at 13:05
  • @BoarGules EXACTLY! I wasn't using the print() so I wasn't receiving an error message. I was receiving nothing. Its working fine now with print(). Thanks! I'll be happy to accept you answer as a solution if you post it. – OvermanZarathustra Apr 17 '21 at 13:10

1 Answers1

1

If you get no error message, and you have shown us your whole program then your problem is that you are expecting time.asctime() on its own to produce output the way it does in IDLE. But to get the same effect in a program that PyCharm runs, you need something like print(time.asctime()). To get PyCharm to do what IDLE does in this case, you need to ask PyCharm to open a Python console.

BoarGules
  • 16,440
  • 2
  • 27
  • 44