0

I try to enter some commands directly in the cmd. The commands work from the IDE PyCharm, but when i try to enter them directly it doesn't work. What do i have to do? I tried to change the direction of the cmd (using cd). Im using windows. I try to do some pip commands but i acctualy have a bigger problem. I am using the spectral toolbox from python. in the File matplotlib there comes the error No module named 'matplotlib._path'.

Florian
  • 1
  • 1
  • Did you add Python to your environment variables ? – SRD Nov 13 '17 at 14:13
  • @Florian, are trying that into Linux or Windows? Moreover can you provide the code what you tried.. – krock1516 Nov 13 '17 at 14:16
  • 1
    @Florian Are you trying to run python commands directly into cmd without starting python? That won't work, you have to start python first (which you can do in cmd by typing python). – en_lorithai Nov 13 '17 at 14:17
  • type python, then press enter to enter the python environment. – EM28 Nov 13 '17 at 14:20
  • I think i added python to my environment variables but i'm not sure if I've done it correctly – Florian Nov 13 '17 at 14:48

2 Answers2

0

The terminal in the PyCharm IDE is probably giving you a python prompt, and hence accepts python commands. The cmd terminal is expecting windows commands instead.

If you start python in the cmd terminal with the command python (or python3) then you should switch to a prompt starting with >>>, at which point you can enter commands.

e.g.

    C:\Users\Ben> python
    Python 2.7
    Type "help", "copyright", "credits" or "license" for more information.
    >>> print("Hello")
    Hello

Alternatively tell us what commands you're trying to run so we have a better idea how to help.

benjsec
  • 23
  • 3
  • Hey i try to run pip commands but they are not working. I've tried your 'hello' command after entering python this one worked well. – Florian Nov 13 '17 at 14:39
  • Recent versions of python on Windows should include pip, but older versions may not - see https://stackoverflow.com/questions/4750806/how-do-i-install-pip-on-windows#12476379 for installation instructions if you don't think it is. Can you include the error messages you're getting on the terminal in your original question too? – benjsec Nov 13 '17 at 15:07
  • Hey the pip commands already worked before so i think it should be included. I think there could be a problem with the sys. path. I had some problems with it from the beginning. there are also other commands which do only work in the IDE and doesn't work in the CMD – Florian Nov 20 '17 at 10:21
0

If you are using Linux then you can try as follows from your command prompt:

just for the example, i imported os module of python and got the OS information with os.uname() command ..

bash-4.1$ python
Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> print os.uname()
    ('Linux', 'noi-karn', '2.6.32-431.11.2.el6.x86_64', '#1 SMP Tue Mar 25 19:59:55 UTC 2014', 'x86_64')
    >>> quit()
bash-4.1$
krock1516
  • 565
  • 5
  • 26