Pip type error.

768 views
Skip to first unread message

John W.

unread,
Mar 10, 2012, 11:06:23 AM3/10/12
to django...@googlegroups.com
Hi. I want to deploy a Django project on Heroku. The logic it's straightforward : create a virtualenv, install django, some other stuff, pip freeze into requirements.txt, create a git repository and git push it to project's repository. From what i've seen it seems like the service downloads the project and install virtualenv and pip on virtual server and it uses pip to install dependencies listed in requirments.txt . While pushing to remote server it looks like everything goes nicely until pip starts to install dependencies and then a error happens. I'm new to pip so maybe someone already seen this error. Thank you in advance.

Console snapshot:

ψ pip.exe freeze
Django==1.3.1
distribute
==0.6.24
versiontools
==1.8.3
(venv)

ψ more .\requirements.txt
Django==1.3.1
distribute
==0.6.24
versiontools
==1.8.3

(venv)

ψ git push heroku master
Enter passphrase for key '/c/Program Files (x86)/Vim/.ssh/id_rsa':
Counting objects: 12, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (12/12), 3.30 KiB, done.
Total 12 (delta 2), reused 0 (delta 0)

-----> Heroku receiving push
-----> Python/Django app detected
-----> Preparing virtualenv version 1.7
       
New python executable in ./bin/python
       
Installing distribute.............................................................................................................................................................................................done.
       
Installing pip...............done.
-----> Activating virtualenv
-----> Installing dependencies using pip version 1.0.2
       
Exception:
       
Traceback (most recent call last):
         
File "/tmp/build_k6zl66ydgqxp/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/basecommand.py", line 126, in main
           
self.run(options, args)
         
File "/tmp/build_k6zl66ydgqxp/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/commands/install.py", line 200, in run
           
for req in parse_requirements(filename, finder=finder, options=options):
         
File "/tmp/build_k6zl66ydgqxp/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 1255, in parse_requirements
           req
= InstallRequirement.from_line(line, comes_from)
         
File "/tmp/build_k6zl66ydgqxp/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/req.py", line 82, in from_line
           
elif os.path.isdir(path) and (os.path.sep in name or name.startswith('.')):
         
File "/tmp/build_k6zl66ydgqxp/lib/python2.7/genericpath.py", line 41, in isdir
           st
= os.stat(s)
       
TypeError: must be encoded string without NULL bytes, not str

       
Storing complete log in /app/.pip/pip.log
 !     Heroku push rejected, failed to compile Python/django app 

John W.

unread,
Mar 11, 2012, 4:17:59 AM3/11/12
to django...@googlegroups.com
I know it's weird to reply to myself, but just in case that somebody has the same problem. 

It seems that the problem it is in the requirements.txt, i created it using powershell and "pip.exe freeze > requirements.txt" command,
which creates a file with a name that has nullbytes in it. 
I was able to get around this problem by downloading a requirements.txt from an example project on github and modifying it.
That did the job and everything works nice.
Message has been deleted

Mark Liu

unread,
Jul 10, 2013, 6:16:32 PM7/10/13
to django...@googlegroups.com
Googled this problem and came here. I was also using powershell but everything worked after I converted the requirments file to utf-8

On Wednesday, May 1, 2013 8:43:13 AM UTC-4, il...@app-loader.com wrote:
Brilliant !
I was using powershell.
When I switched back to good old cmd.exe pip freeze worked fine

On Saturday, July 21, 2012 9:00:50 AM UTC+3, Jauharul Fuady wrote:


On Sunday, 11 March 2012 15:17:59 UTC+7, John W. wrote:
I know it's weird to reply to myself, but just in case that somebody has the same problem. 

It seems that the problem it is in the requirements.txt, i created it using powershell and "pip.exe freeze > requirements.txt" command,
which creates a file with a name that has nullbytes in it. 
I was able to get around this problem by downloading a requirements.txt from an example project on github and modifying it.
That did the job and everything works nice.

 
Thank you for posting it. It helps me.

Dylan F.

unread,
Mar 27, 2014, 10:06:00 AM3/27/14
to django...@googlegroups.com
Thanks Brian! The out-file command with ascii encoding specified fixed this for me. 

On Wednesday, September 26, 2012 1:55:31 AM UTC-4, Brian Peiris wrote:
Thanks John, that was useful.
This happens because powershell outputs UTF-16 by default. Another way to fix it is by using the out-file command with an ascii encoding specified:

pip freeze | out-file -enc ascii requirements.txt

Timmy Blumberg

unread,
Jun 21, 2014, 2:49:09 AM6/21/14
to django...@googlegroups.com
This is a much needed solution to a problem that has been plaguing my development cycle for weeks. Many "thankyous", stranger.

sasidhar puranam

unread,
Oct 30, 2014, 2:29:31 PM10/30/14
to django...@googlegroups.com, tblum...@gmail.com
Thank you ..it helped !
Reply all
Reply to author
Forward
0 new messages