PyCharm different Environment when starting Terminal vs. Starter?

i am using Pycharm with LInux Mint - when ich start the program directly from the Terminal with ./pycharm.sh everything seems to be fine with the interpreter - all the modules are installed and available:
https://drive.google.com/file/d/1bxfz40LZf8g5zVT1kuvPbrjvOvI0iKXI/view?usp=sharing

But when i start the exact sh-file with a starter from the desktiop i cant see the modules anymore in the interpreter:
https://drive.google.com/file/d/14bwvobzuqy_OfIytFQwSrxyUub1cIiWV/view?usp=sharing

How can this be?
Only the call of the program is different...?

10 comments
Comment actions Permalink

Hi, this is likely due to different environments in your terminal vs desktop session. How did you install this interpreter? 

Try doing `~/GitHub/bin/python -m pip list` from your terminal, what is the output? 

Compare PATH and PYTHONPATH variables after starting PyCharm from both places - are there differences? 

0
Comment actions Permalink

Hallo,

i think i haven`t installed anything regarding the python interpreter - python 3.6. should be allready installed in the linux mint distribution i think.
Pycharm itself was installed with this instruction: https://www.jetbrains.com/help/pycharm/installation-guide.html

This is the output of the list statement:
rapid1898@rapid1898-B85-HD3:~$ ~/GitHub/bin/python -m pip list
Package Version
-------------- ----------
beautifulsoup4 4.9.1
bs4 0.0.1
certifi 2020.4.5.2
chardet 3.0.4
get 2019.4.13
idna 2.9
pip 20.1.1
post 2019.4.13
public 2019.4.13
pygame 1.9.6
query-string 2019.4.13
request 2019.4.13
requests 2.23.0
setuptools 47.1.1
soupsieve 2.0.1
urllib3 1.25.9

Starting from both places - <Settings> - <Appearance & Behavior> - <Path Variable> are completely empty.

 

 

 

0
Comment actions Permalink

How did you create the desktop shortcut? Did you do it from PyCharm? (Tools | Create desktop entry)

Please start PyCharm from desktop, open terminal and do `which python` - should point to "~/GitHub/bin/python"

Then `which pip` - where does it point to?

Also `echo $PATH` - please provide the output.

0
Comment actions Permalink

I created the shortcut directly on the desktop with right mouseclick on it and selected starter - there i choose the python.sh-file (the same which i start from the terminal).

These are the informations (PyCharm from desktop):
(but this are exactly the same informations as when ich open PyCharm from the terminal - the only difference you can see in the link above regarding the modules...)

(GitHub) rapid1898@rapid1898-B85-HD3:~/Dokumente/GitHub$ which python
/home/rapid1898/GitHub/bin/python

(GitHub) rapid1898@rapid1898-B85-HD3:~/Dokumente/GitHub$ which pip
/home/rapid1898/GitHub/bin/pip

(GitHub) rapid1898@rapid1898-B85-HD3:~/Dokumente/GitHub$ echo $PATH | tr ":" "\n" | nl
1 /home/rapid1898/GitHub/bin
2 /home/rapid1898/.local/bin
3 /home/rapid1898/bin
4 /usr/local/sbin
5 /usr/local/bin
6 /usr/sbin
7 /usr/bin
8 /sbin
9 /bin
10 /usr/games
11 /usr/local/games
12 /snap/bin

0
Comment actions Permalink

Could you try creating a desktop entry from the Tool menu? 

If this doesn't help, try to recreate the interpreter using absolute path (i.e. no ~ in the path)

0
Comment actions Permalink

Tried creating a new desktop entry - but the same problem

But then i recreated the python interpreter and choosed under existing environment the python3.6 program under /usr/bin/python3.6
And that was it!
Now it shows me with the project interpreter "Python 3.6. /usr/bin/python3.6" all the installed modules - no matter i start pycharm from desktop or terminal

Thank you very much for your help!

May I can bother yoiu with an addtional question?
There is only one problem left with the modules in PyCharm - and it is about Selenium

When i start a program with selenium i got this error.
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

So i tried to add this path - where the chromedriver.exe is located:
https://drive.google.com/file/d/1_Cc66GNZiVLSGrHARz1rClUDT5gATDw2/view?usp=sharing

But i stil get this error...

 

 

 

 

 

0
Comment actions Permalink

You should modify env variable in run/debug configuration instead: https://www.jetbrains.com/help/pycharm/creating-and-editing-run-debug-configurations.html

And make sure it's $PATH:<new_path>, otherwise you will overwrite your current path instead of appending.

0
Comment actions Permalink

Tried to change this in the window Run/Debug Configurations like this:
https://drive.google.com/file/d/1sEpakypg6rES7Fj3CCGciQdwNUiTKtH0/view?usp=sharing

But also with this setting i get the same error message regarding chromedriver...

 

 

 

0
Comment actions Permalink

Sorry, but you do it wrong - the name of the variable should be PATH and the value should be $PATH:<new_path_you_want_to_add>

Also your path contains spaces which I strongly advice against. Good practice in programming is to not have spaces in your paths.

0
Comment actions Permalink

Thank you very much - now it is working

0

Please sign in to leave a comment.