سؤال

So I tried to change PYTHONPATH in mac terminal and this is how it went:

>>> PYTHONPATH = "${PYTHONPATH}:~/Desktop/Python/Modules"
>>> export PYTHONPATH
File "<stdin>", line 1
export PYTHONPATH
                ^
SyntaxError: invalid syntax

What am I doing wrong?

هل كانت مفيدة؟

المحلول

When you type PYTHONPATH, you are typing in a command that is meant for your shell, not necessarily the python interpreter -- that is why you're getting a syntax error. What you want to do is set the pythonpath before you start the interpreter. When you set PYTHONPATH, you essentially give python's sys module another path in which to look for modules.

So like @Blender said, you'll want to start your terminal again, and from there, you'll want to type those two last commands again.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top