New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`ImportError: No module named platformio.util` on platformio run #9

Closed
ariejan opened this Issue Aug 4, 2014 · 9 comments

Comments

Projects
None yet
2 participants
@ariejan

ariejan commented Aug 4, 2014

I have a very simple project, see https://gist.github.com/ariejan/3cd2986afb67e054ba46 for the src/main.cpp and platformio.ini. Both are basically a copy of the examples provided by platformio.

I'm on OS X 10.9, with Python 2.7 through home brew:

$ which python
/usr/bin/python

$ python --version
Python 2.7.5

I can install and list frameworks just fine:

$ platformio list
atmelavr    with packages: toolchain-atmelavr, tool-avrdude, framework-arduinoavr

$ platformio show atmelavr
atmelavr    - An embedded platform for Atmel AVR microcontrollers (with Arduino Framework)
----------
Package: toolchain-atmelavr
Alias: toolchain
Location: /Users/ariejan/.platformio/atmelavr/tools/toolchain
Version: 1
----------
Package: tool-avrdude
Alias: uploader
Location: /Users/ariejan/.platformio/atmelavr/tools/avrdude
Version: 1
----------
Package: framework-arduinoavr
Location: /Users/ariejan/.platformio/atmelavr/frameworks/arduino
Version: 4

However, when I try to run this, I get the following error:

$ platformio run
Processing arduino_mega environment:

ImportError: No module named platformio.util:
  File "/usr/local/lib/python2.7/site-packages/platformio/builder/main.py", line 9:
    from platformio.util import (get_home_dir, get_pioenvs_dir, get_project_dir,

Since I'm not all that familiar with Python, I've got no clue as to how to resolve this. There is a util.py file at `` that contains the methods mentioned.

$ ls -alhd /usr/local/lib/python2.7/site-packages/platformio/*
-rw-r--r--   1 ariejan  admin   513B  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/__init__.py
-rw-r--r--   1 ariejan  admin   741B  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/__init__.pyc
-rw-r--r--   1 ariejan  admin   2,1K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/__main__.py
-rw-r--r--   1 ariejan  admin   3,1K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/__main__.pyc
drwxr-xr-x   8 ariejan  admin   272B  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/builder
drwxr-xr-x  24 ariejan  admin   816B  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/commands
-rw-r--r--   1 ariejan  admin   2,5K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/downloader.py
-rw-r--r--   1 ariejan  admin   3,9K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/downloader.pyc
-rw-r--r--   1 ariejan  admin   2,4K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/exception.py
-rw-r--r--   1 ariejan  admin   5,3K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/exception.pyc
-rw-r--r--   1 ariejan  admin   4,8K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/pkgmanager.py
-rw-r--r--   1 ariejan  admin   6,6K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/pkgmanager.pyc
drwxr-xr-x  12 ariejan  admin   408B  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/platforms
-rw-r--r--   1 ariejan  admin   2,5K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/projectconftpl.ini
-rw-r--r--   1 ariejan  admin   2,2K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/unpacker.py
-rw-r--r--   1 ariejan  admin   4,5K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/unpacker.pyc
-rw-r--r--   1 ariejan  admin   2,1K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/util.py
-rw-r--r--   1 ariejan  admin   4,0K  4 aug 16:38 /usr/local/lib/python2.7/site-packages/platformio/util.pyc

What am I missing? What do I need to to fix my environment?

@ivankravets

This comment has been minimized.

Member

ivankravets commented Aug 4, 2014

Thanks a lot for report.

  1. Which way did you use to install PlatformIO?
  2. Try close/open your Terminal application.

Is it working fine now? If no, then give me a list of installed Python packages:

$ pip list

@ivankravets ivankravets added question and removed question labels Aug 4, 2014

@ariejan

This comment has been minimized.

ariejan commented Aug 4, 2014

  1. pip install platformio & pip install --egg scons (Note the single & as I'm using Fish)
  2. Here you go
$ pip list
base58 (0.2.1)
BeautifulSoup (3.2.1)
bsddb3 (6.0.1)
click (2.5)
doge (3.4.0)
ecdsa (0.10)
GDAL (1.11.0)
mercurial (3.0.2)
PIL (1.1.7)
pip (1.5.6)
platformio (0.5.0)
pycoin (0.23)
Pygments (1.6)
pyserial (2.7)
requests (2.3.0)
setuptools (5.4.2)
vboxapi (1.0)
wsgiref (0.1.2)

I already tried the termanial-hop, been there done that.

@ivankravets

This comment has been minimized.

Member

ivankravets commented Aug 4, 2014

I know another way how to resolve this issue. But I want to know why this normal way (with installation) doesn't work. Something is wrong with your PYTHONPATH. I've just created "debug" version of main.py file.

Please replace file /usr/local/lib/python2.7/site-packages/platformio/builder/main.py with https://gist.github.com/ivankravets/e3ee819d8c453c37e5ae

The run for your test project:

$ platformio run

You should see a dump of Python system path. Please share it here.

Thanks a lot.

@ariejan

This comment has been minimized.

ariejan commented Aug 4, 2014

Here you go:

$ platformio run
Processing arduino_mega environment:
['/usr/local/lib/python2.7/site-packages/platformio/builder', '/usr/local/bin/scons-local-2.3.0', '/usr/local/bin/scons-local', '/usr/local/lib/scons-2.3.0', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/scons-2.3.0', '/usr/local/lib/python2.7/site-packages/scons-2.3.0', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scons-2.3.0', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/scons-2.3.0', '/usr/local/lib/scons', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/scons', '/usr/local/lib/python2.7/site-packages/scons', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/scons', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/scons', '/Library/Python/2.7/site-packages/Pygments-1.6-py2.7.egg', '/Library/Python/2.7/site-packages/PIL-1.1.7-py2.7-macosx-10.9-intel.egg', '/Library/Python/2.7/site-packages/BeautifulSoup-3.2.1-py2.7.egg', '/Library/Python/2.7/site-packages/bsddb3-6.0.1-py2.7-macosx-10.9-intel.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']
ImportError: No module named platformio.util:
  File "/usr/local/lib/python2.7/site-packages/platformio/builder/main.py", line 12:
    from platformio.util import (get_home_dir, get_pioenvs_dir, get_project_dir,

You are not trying to steal my passwords are you? 😉

@ivankravets

This comment has been minimized.

Member

ivankravets commented Aug 5, 2014

I see a problem. It is /usr/local/lib/python2.7/site-packages/platformio/builder. Something is wrong with your Python Interpreter when code is run from subprocess. The valid item in PythonPath in your case is /usr/local/lib/python2.7/site-packages.

Do you run $ platformio run command with sudo permissions? If yes, try without sudo.

I will create simple "patch" for your case and give your a new main.py. If it works for you, I will merge it to develop branch.

P.S:

You are not trying to steal my passwords are you?

No, I'm a good man :)

@ariejan

This comment has been minimized.

ariejan commented Aug 5, 2014

Running with sudo gives the same output as without sudo.

@ivankravets

This comment has been minimized.

Member

ivankravets commented Aug 5, 2014

Try new main.py:

Please replace file /usr/local/lib/python2.7/site-packages/platformio/builder/main.py with https://gist.github.com/ivankravets/e3ee819d8c453c37e5ae

@ariejan

This comment has been minimized.

ariejan commented Aug 5, 2014

Yes, that works. Well, I get a compile error on my own code, so that's good.

👍

ivankravets added a commit that referenced this issue Aug 5, 2014

@ivankravets

This comment has been minimized.

Member

ivankravets commented Aug 5, 2014

Thanks a lot you for patience with several patches! 😉

@ivankravets ivankravets closed this Aug 5, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment