I'm a newbie and I'm trying to run some scripts in Python for my university classes. I had to install MacPorts but I installed some Python versions before... My script has this:
import sys
sys.path.append("/Users/matteo/Dropbox/tesi_magistrale/lmgc90_user/build")
import telepot
import time
from pprint import pprint
I used the sys.path.append
because I need that folder if I want to use a software for my thesis.
When I run the script I have:
MacBook-Pro-di-Matteo-2:telegram matteo$ python bot.py
Traceback (most recent call last):
File "bot.py", line 15, in <module>
import telepot
ImportError: No module named telepot
But I typed:
MacBook-Pro-di-Matteo-2:telegram matteo$ pip install telepot
Requirement already satisfied: telepot in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/telepot-12.3-py2.7.egg
Requirement already satisfied: urllib3>=1.9.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from telepot)
If I type:
MacBook-Pro-di-Matteo-2:telegram matteo$ which python
/opt/local/bin/python
MacBook-Pro-di-Matteo-2:telegram matteo$ which -a python
/opt/local/bin/python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python
MacBook-Pro-di-Matteo-2:telegram matteo$ which pip
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
MacBook-Pro-di-Matteo-2:telegram matteo$ which -a pip
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
/usr/local/bin/pip
My .bash_profile has these lines:
# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
##
# Your previous /Users/matteo/.bash_profile file was backed up as /Users/matteo/.bash_profile.macports-saved_2017-09-12_at_16:05:41
##
# MacPorts Installer addition on 2017-09-12_at_16:05:41: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
I use a Mac with Yosemite 10.10.4. I have this problem with "telepot" package and all the others, like panda3d, matplotlib etc. Thank you!
Your pip
using a different python executable then python
command invoked
You could re-install pip with python get-pip.py
, newly installed pip bin will be aligned with python executable in use, then install your packages, they should work.
But I suggest you clean up your local python installations and $PATH
setting afterward.