1

When I write a simple code in PyCharm:

import setuptools
a = 10  ## This line is of no use

I don't get any error while executing it. But if I try to import setuptools from the terminal I get an error that there is no module named setuptools. What I write at the terminal is:

python3 -c "import setuptools"

I have setuptools installed for python 2.7 and I have tried the same for 2.7 version also and it runs at both the places i.e. terminal and PyCharm.

Pukki
  • 586
  • 1
  • 7
  • 18
  • where did you see that you could not have setuptools in python3? https://pypi.python.org/packages/3.4/s/setuptools/setuptools-17.1.1-py2.py3-none-any.whl#md5=8a540687a8341088e2b280ad2ceb4e5b – Padraic Cunningham Jun 11 '15 at 10:36
  • Here, maybe it is outdated: http://stackoverflow.com/questions/6587507/how-to-install-pip-with-python-3 – Pukki Jun 11 '15 at 10:47
  • That was back in 2011 – Padraic Cunningham Jun 11 '15 at 10:48
  • OK. But still my original question remains unanswered. I am using python3.4 interpreter when using pycharm to run that simple code. – Pukki Jun 11 '15 at 10:57
  • Then you have more than one version of python3 installed or you are using the python2 interpreter inp ycharm as the project interpreter – Padraic Cunningham Jun 11 '15 at 10:58
  • I checked again but I am using python interpreter 3.4.0 in pycharm and have only that version installed other than 2.7.6. I used python -V and python3 -V to check the versions from terminal also. I have only these two versions installed as far as I could gather from this test. – Pukki Jun 11 '15 at 11:07
  • then `which -a python3` and I will be surprised if there is only one – Padraic Cunningham Jun 11 '15 at 11:13
  • Yes one at: usr/local/bin/python3 and one at usr/bin/python3. How do I rectify this. Thanks in advance. – Pukki Jun 11 '15 at 11:18
  • I would keep `usr/bin/python3` remove `usr/local/bin/python3` then update pip with get-pip.py, there are other options but it is not really worth having two versions of the same python installed as it only leads to the problems you have experienced. If you wanted other versions use a venv – Padraic Cunningham Jun 11 '15 at 11:19

1 Answers1

-1

Looks like the environment setup by pycharm doesn't match the one you have in your terminal.

Try to display sys.path in your script executing in pycharm and adjust your PYTHONPATH env var to be inline with it.

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97