2

I have been trying to deploy a python script to Iron.io. They recommend using docker to test locally before uploading.

I have completed their provided docker/iron tutorial without error.

So I started to modify the provided requirements.txt from their sample repo to start my own project, but whenever I try to install the packages locally I receive a TypeError.

My pip is version:

pip 7.1.2 from /Library/Python/2.7/site-packages (python 2.7)

Their requirements.txt

iron-mq>=0.5
iron-worker>=1.3.1

My requirements.txt

iron-mq>=0.5
iron-worker>=1.3.1
beautifulsoup4
html5lib

Terminal command:

$ docker run --rm -v "$PWD":/worker -w /worker iron/python:2-dev pip install -t packages -r requirements.txt

Error:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 282, in run
    wheel_cache
 File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 291, in populate_requirement_set
    wheel_cache=wheel_cache):
 File "/usr/lib/python2.7/site-packages/pip/req/req_file.py", line 89, in parse_requirements
    for req in req_iter:
 File "/usr/lib/python2.7/site-packages/pip/req/req_file.py", line 137, in process_line
    isolated=isolated, options=req_options, wheel_cache=wheel_cache
 File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 168, in from_line
    if (os.path.isdir(p) and
 File "/usr/lib/python2.7/genericpath.py", line 49, in isdir
    st = os.stat(s)
 TypeError: must be encoded string without NULL bytes, not str

I am using Sublime on OSX and encoding with UTF-8. Other threads regarding this error are usually resolved by escaping some characters or changing the encoding. But I couldn't find an alternative encoding to use.

Is there a trick to saving requirements without any null bytes? Or is there another known fix?

Edit update:

Running with -vvv max verbose mode for pip

docker run --rm -v "$PWD":/worker -w /worker iron/python:2-dev pip install -vvv -t packages -r requirements.txt

Returned

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 211, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 282, in run
    wheel_cache
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 291, in populate_requirement_set
    wheel_cache=wheel_cache):
  File "/usr/lib/python2.7/site-packages/pip/req/req_file.py", line 89, in parse_requirements
    for req in req_iter:
  File "/usr/lib/python2.7/site-packages/pip/req/req_file.py", line 137, in process_line
isolated=isolated, options=req_options, wheel_cache=wheel_cache
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 168, in from_line
    if (os.path.isdir(p) and
  File "/usr/lib/python2.7/genericpath.py", line 49, in isdir
    st = os.stat(s)
TypeError: must be encoded string without NULL bytes, not str
Starting new HTTPS connection (1): pypi.python.org
"GET /pypi/pip/json HTTP/1.1" 200 50975

The only new output was the two lines at the bottom.

Running iconv to identify any rogue characters just returns the contents of the txt file.

iconv -t UTF-8 requirements.txt

iron-mq>=0.5
iron-worker>=1.3.1
beautifulsoup4==4.4.1
Devin
  • 205
  • 2
  • 13
  • What version of pip are you using? Have you tried upgrading to the latest version? Also, can you try the install command with max verbosity enabled? (`pip install -vvv ...`) – John Carter Jan 10 '16 at 07:56
  • It does sound like you have some rogue special characters in your requirements file - see comments on this similar question https://stackoverflow.com/questions/30816367/heroku-string-without-null-bytes-with-several-requirements-files – John Carter Jan 10 '16 at 08:08
  • @therefromhere pip version and additional output added to original post. – Devin Jan 10 '16 at 16:39

2 Answers2

0

I had the same trouble trying to run pip install on my Mac with the Iron docker images. After trying a bunch of things to fix it, I tracked the problem down to Docker Toolbox and vboxfs. They weren't syncing host filesystem changes properly. To fix it, in the docker toolbox VM I ran:

sync; echo 3 > /proc/sys/vm/drop_caches

The sync call syncs any pending writes to disk. The second command tells the kernel to clear the filesystem caches.

Once I did that my pip install worked fine.

skwashd
  • 101
  • 2
0

On Windows and Mac OS, Docker Daemon runs on a virtual machine.

Try to enter the virtual machine and run the Docker commands there. A possible work around for this issue is to avoid running Docker commands on host machine.

As a reminder, Iron.io's support is available via phone, email or chat for additional questions.