pythonbrew does not install python with no output on command line - pythonbrew

I'm new to both python, pythonbrew and ubuntu. I need python 2.6 and currently have 2.7 on my ubuntu precise system. Searching online revealed that I should not try to uninstall 2.7 as that would pretty much destroy the OS, but get pythonbrew instead, that manages multiple python installations.
I tried installing pythonbrew, but the curl install (curl -kL https://raw.githubusercontent.com/utahta/pythonbrew/master/pythonbrew-install | bash) did not work for me: it was not picking up my http proxy from env, and then not passing it to the install script, once I provided it on the command line. I downloaded the pythonbrew bits manually and then used python setup.py install to install it. I did it as root and it seemed to work (installing under /root/.pythonbrew, which was not the best), however I could not use it as a different user on the system (permission problems). After some more reading I executed the script correctly as root user and it installed pythonbrew to /usr/local/pythonbrew (yay).
Now, when I execute the following as root or non root user, it waits for a while and then the prompt comes back with no error or any other information (--verbose makes no difference):
root#xxx:~/.pythonbrew/scripts/pythonbrew# pythonbrew install 2.6
root#xxx:~/.pythonbrew/scripts/pythonbrew#
Any ideas? I'm guessing this has something to do with the proxy again, but I'm completely new to python so any pointers are welcome.

Following the "which pythonbrew" and doing some guessing the following solved my problem: I changed the curl.py file under /usr/local/pythonbrew/scripts/pythonbrew adding proxy setting to read, readheader and fetch functions as follows:
before modification:
p = Popen('curl -skL "%s"' % url, stdout=PIPE, shell=True)
after modification:
p = Popen('curl -x http://<proxy host>:<proxy port> -skL "%s"' % url, stdout=PIPE, shell=True)
I am not sure why there was no output without the proxy setting, but now the install works!

I also faced this issue today, while installing py2.7.14 with pythonbrew.
The reason it silently fails to install is when it gets the header from the python server (src of py2.7.14), it checks for a return status of success. It implements HTTP/1.1 method check (only) where successful return status is 200 OK.
However, python server uses HTTP/2 and the success return code is in the form 200, there's no trailing OK.
So, to fix it, I added 2 lines of code below following 2 lines in /opt/.pythonbrew/scripts/pythonbrew/curl.py, routine readheader().
if re.match('^HTTP.*? 200 OK$', line):
break
Added this code below above code:
elif re.match('^HTTP.*? 200$', line):
break
I did't want to change pythonbrew's code, hence added it with an elif.
This works.
I note that several other people using pyenv also mentions of similar issue, I am presuming similar issue may exist there.

Related

Cannot run git clone or pip install commands

So i'm pretty new to the whole windows repo cloning thing. I installed python 2.7, added the path to my windows cmd and I still cannot run any git clone commands. It shows the following output :
git clone
File "", line 1
git clone
^
I've been scouring the internet for an answer but apparently it should work if I use cmd.
Any help would be appreciated!
git clone
File "", line 1
git clone
^
I have had the same issue recently with 3.7, so I made a new username and it worked. Kind of nice, a clean new Windows profile, even though I just started using it again compared to linux. A pain though.
Make sure all other versions of Python are not installed, or at least affecting the path to the file you need the pip installs to be saved. Python can be saved in a few different locations, and some rare times it has been shown in very obscure places. Check where your file saved on your PC. Probablu C:/ then could be many paths. /Users/UnserNameHere/Windows/ProgramFiles. I would use the search bar in the good old GUI while searching under the C drive (if you have multiple HDD/SDD then pic the one used for the C drive, if nothing comes up try the other drives.
Your looking for a file PythonFoundation I can't remember the entire name, however it will have a very long name Python Foundation are in the name of the file. This is where thing are store and where the path should be sending modules, at least the correct file inside that file.
Also try doing it from other Python versions installed. If you had 3.6 and got 3.7 it doesn't mean 3.6 has been deleted. Also doesn't mean you path, is not set to 3.6 while using 3.7. Same with Python 2, most people or many have both. The pip commands vary between python versions pip3 I believe is used (getting windows and linux a little mixed up right now)
If all fails do it the old fashon way, find the mod, download it, and move it to the python file I mentioned above. The homepage for python should have a tab linking to a page, or it's on the main page, letting you know where it has been known to save. Google how to see he path Pip is taking, or how to see if pip is installed and where, and what paths are set to.

transcrypt issue - cannot run the sample program

Followed the instructions in transcrypt "getting started" docs, I entered the examples 'hello.html' and 'hello.py' in a separate directory.
Entering from the command line: "transcrypt -b -m hello.py" resuleds in the error message: "'transcrypt' is not recognized as an internal or external command,
operable program or batch file."
I'm using python3.6, with transcrypt installed in: C:\program files\python36\lib\site-packages\transcrypt
Any help to activate the sample hello.html would be appreciated.
Could you try python -m transcrypt -b -m hello.py
and tell me what the console output is?
Also: are you on Windows, Linux or OsX?
Answer: Windows 10
[EDIT 1]
Looks like Transcrypt was installed under a different Python distro. Would be good to know what's going on, so please keep us informed. I also have several Python installs on my Windows 10 computer and it can be confusing indeed.
[EDIT 2]
Another possibility is manual installation (although it isn't elegant...). From the docs
http://www.transcrypt.org/docs/html/installation_use.html#installation-troubleshooting-checklist
Alternatively, for manual installation under Windows or Linux, follow
the steps below:
Download the Transcrypt zip and unpack it anywhere you like
Add ../Transcrypt-/transcrypt to your system path
To enable minification, additionally the Java Runtime Environment 6 or later has to be installed
Note If you install Transcrypt manually, Trancrypt is started by typing run_transcrypt rather than transcrypt. This allows a pip
installed Transcrypt and a manually installed Transcrypt to be used
side by side selectively
BTW Thanks for the suggestion on Github. We'll look into it and try to improve the docs on this point. It seems to be quite difficult to really draw up a bullet proof installation procedure for each platform.
You might also find it easier to use python3's built in virtual env, so that you install Transcrypt and other python modules only into one project folder at a time. It's much easier to use than it at first sounds.
Here's how you might do that on Windows 10.
mkdir mynewproject
cd mynewproject
py -3 -m venv myvirtualenv # installs venv files into myvirtualenv
myvirtualenv\Scripts\activate # activates the virtual env
The py -3 command uses the python windows launcher to use the latest version of python 3. The launcher is defined in Pep 397 and the docs are here.
Once the virtual environment is activated, the prompt will change to show that. After which any 'pip install' commands will install packages into 'myvirtualenv', instead of the system wide location. If you want to deactivate it, just type 'deactivate' or close the shell window. You can also just use 'python' to refer to python3 from within the virtual env. This has saved many people from madness.
In case this helps for other newbies. A few problems I encountered when setting up transcrypt.
Path issues: I had multiple versions of python, in different folders: \python26, \python27, and \Program Files\python36.
This caused all sorts of grief, despite setting the environmental path to include the python36 distro. I fixed this issue by renaming the other versions \python26x and \python27x. This left those distros intact if ever I needed to use them, but stopped the system from finding them. Thus, it only found python36
My earlier suggestion of py -3 didn't really solve the multiple distro issue completely after all.
After doing that, I reinstalled transcrypt and it seemed OK (sort of: read on)
Second issue was trying to run the sample hello.py. I tried "transcrypt -b hello.py" and got a "'transcrypt' is not recognized.." message.
But this worked: python -m transcrypt -b -m hello.py
That worked because the system had finally found the correct version of python, due to the above fix.
Similarly, trying to run the sample hello.py as recommended in the docs caused a problem. run_transcrypt -b hello.py
The reason for this was that run_transcrypt resolved to "python $(dirname $0)/main.py $*"
But, because I had python v3.6 installed in c:\Program Files, the batch file run_transcrypt caused this output:
c:\transcrypt>python C:\Program Files\Python36\Lib\site-packages\transcrypt__main__.py -b hello.py
python: can't open file 'C:\Program': [Errno 2] No such file or directory
Consequently, I had to place Program Files in quotes and run it this way:
"C:\Program Files"\Python36\Lib\site-packages\transcrypt__main__.py -b hello.py
or else, as above: python -m transcrypt -b -m hello.py
I think, with respect, the docs should raise a warning flag here for users who have python installed in \Program Files, rather than, for example, in c:\python[x]
Third issue Changing hello.py to "play around" with the code -
I found the files in transcrypt\demos\ to be read-only. To fix this:
1: I opened the command prompt as administrator
2: I ran the attrib command to change the file attributes:
"c:\Program Files\Python36\Lib\site-packages\transcrypt\demos\hello>attrib -r -s -a hello.py"
(Without doing this as administrator you get an access-denied message)
The whole exercise caused a few hours of toing and froing, but it seems that things are better now.

package download fails , "GOPATH not set." why?

OS: Ubuntu 12.04
Go version reporting: 1.1.1
Action:
I have configured the .profile to contain the following lines:
export GOPATH="$HOME/workspace"
export PATH=$PATH:$GOPATH/bin
I have ensured that they are set in the go configuration by running "go env". However when I try to run the command, the screen reports as shown in the image below:
Possible constraining issues:
1) The box originally had Go v1.0 on it and I upgraded it to go version1.1.1, not sure that should mean anything...but if there is some twin configuration madness at work that may explain the fact it's not working despite the path being set.
2) I had the export commands in the .profile file but I see some threads indicate to put it in .bashrc, trying in either still gives the same problem.
Do I need to uninstall go 1.0 ? I just assumed version 1.1.1 would over ride it but that could be wrong. Ideally I wanted to uninstall go entirely and then install version 1.1.2 but I couldn't find anything at golang.org on uninstalling assuming that does solve the problem.
Thanks in advance for any assistance.
As the commenter above stated, you should not use sudo with go get. When you do, you have the root user's environment (which doesn't have your GOPATH) and any files or directories it creates won't be editable by your user. In the past, the go get command would not warn about not having a $GOPATH and so it was easier to get tripped up by this.
To fix your permissions, run the following command to change ownership back to your user:
sudo chown -R "$USER:" "$GOPATH"
You should only ever need to run a plain go get because you can (and should) set your $GOPATH to be a directory you can control. Be sure to read the How To Write Go Code and in particular its discusson on GOPATH.

Problems installing Python Protocol Buffers

I am a beginning programmer trying to install the Python Protocol Buffers from this package: http://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.4.1.zip
The readme states:
1) Make sure you have Python 2.4 or newer. If in doubt, run:
$ python -V
2) If you do not have setuptools installed, note that it will be
downloaded and installed automatically as soon as you run setup.py.
If you would rather install it manually, you may do so by following
the instructions on this page:
http://peak.telecommunity.com/DevCenter/EasyInstall#installation-instructions
3) Build the C++ code, or install a binary distribution of protoc. If
you install a binary distribution, make sure that it is the same
version as this package. If in doubt, run:
$ protoc --version
4) Run the tests:
$ python setup.py test
If some tests fail, this library may not work correctly on your
system. Continue at your own risk.
Please note that there is a known problem with some versions of
Python on Cygwin which causes the tests to fail after printing the
error: "sem_init: Resource temporarily unavailable". This appears
to be a bug either in Cygwin or in Python:
http://www.cygwin.com/ml/cygwin/2005-07/msg01378.html
We do not know if or when it might me fixed. We also do not know
how likely it is that this bug will affect users in practice.
5) Install:
$ python setup.py install
This step may require superuser privileges.
NOTE: To use C++ implementation, you need to install C++ protobuf runtime
library of the same version and export the environment variable before this
step. See the "C++ Implementation" section below for more details.
I have added both python and version 2.4.1 of protoc.exe into my PATH. However, when I try to run the test, I get an error message that says there's invalid syntax on line 38:
print "Can't find required file " + source
Okay, so it's missing parenthesis. I add them, and it encounters two more print statement syntax error messages. I fix those, and it encounters a syntax error message on an 'except' statement. What am I doing wrong?
Thanks.
Perhaps you are using Python 3?
The code you refer to will only work in Python 2.X
I have followed same steps , but I didn't get any errors.
Please make sure that you are getting correct Python and protoc version.
Export the environment LD_LIBRARY_PATH variable.

How to set env variables when compiling Node on Windows, from Mingw32?

I'm following the instructions from various Wikis on how to compile Node so I can eventually get it running as a service on Windows.
My steps so far:
https://github.com/joyent/node/wiki/Installation
(which lead to...)
http://blog.tatham.oddie.com.au/2011/03/16/node-js-on-windows/
(successfully compiled via cygwin, but lead to...)
https://github.com/joyent/node/wiki/Building-node.js-on-mingw
(which apparently is better than the so far successful cygwin compile)
So - I've managed to compile Node.exe using Cygwin but not the preferred Mingw. I concur this isn't an ideal situation, building on Windows isn't the ideal. Nevertheless.
The error I see in Mingw, once I've followed all of the steps above, occurs when I try to ./configure --without-ssl. The error message is:
Danjah#PC /c/cygwin/home/Danjah/node-v0.4.7/node
$ ./configure –without-ssl
/usr/bin/env: python: No such file or directory
I understand from step 3's URL, that I must take steps to provide the environment variables for both Python and Git - using help from the provided URL I managed to input the Python path var, but I don't think I have the Git path var right. Either way, in no install directories for Python, Cygwin or Mingw32 do I see the path specified in the error msg: "/usr/bin/env".
Googling didn't really bring much to the table in terms of env variables or Mingw32, best I got was: PATH=C:\MinGW\bin;C:\MinGW\msys\1.0\bin where my install directory is at C:\MingW\.
The path I added to Windows environment vars for Python was: PythonPath=C:\Python27;C:\Python27\DLLs;C:\Python27\Lib;C:\Python27\Lib\lib-tk where Python 2.7 is installed in C:\Python27\.
I hate it when a file path stops you from doing things, as I suspect is the problem here. So please set me straight here - is it a file path problem I have or something else? And if its something else, please try and help me to get Node up and running... keen as to get experimenting.
I should probably also mention that I do also have a previously installed version of Git on my Windows XP SP3 machine, but had not previously had Cygwin, Mingw32 or Python installed, and I do not have IIS running as a service - my usual testing environment is a WAMP stack.
Windows uses the PATH environment variable to locate programs that are invoked without a fully qualified file path, i.e. 'python' rather than 'C:\Python27\python'.
So you need to add python's home directory to the Windows PATH variable, as well as MinGW, git and anything else your script requires.
Also by setting the PATH variable explicitly in your shell session or script, you are overwriting its original contents (in the local context) which limits which programs your shell can find to only those available within the PATH which is usually a bad idea.
See http://www.java.com/en/download/help/path.xml for details on modifying your PATH so you can always run your Python scripts from the command line.

Resources