Some downloads are failing due to Python not being built with the --enable-shared tag, is there some way to get rid of the version I have and rebuild python? Or even better, just change it without reinstalling?
You can rebuild python, and pass --enable-shared to ./configure
Just follow:
For python 3:
https://docs.python.org/3/using/unix.html#building-python
For Python 2:
https://docs.python.org/2/using/unix.html#building-python
Be careful with the things in your distribution that require python, make sure you set the Python Path properly. And check if any of them requires any special configuration flags.
You can install different Python versions (side-by-side even) using pythonz: http://saghul.github.io/pythonz/
Basically, after installing it, you run a command to download and install Python with the version you want:
pythonz install 3.5.1
To pass custom compiling options, use --configure "... options here" as per documentation here.
It even supports PyPy and Jython.
I've been using it with success for the past year or so, it has made my life of testing projects in different Python versions much easier -- highly recommended.
Get sources with:
apt-get source python2.7
in the downloaded directory, change in python2.7.../debian/rules:
with_interp := static
#with_interp := shared
to
#with_interp := static
with_interp := shared
Then at the same level as the debian directory, run dpkg-buildpackage. You'll get ready .deb packages one directory higher. Just install them with dpkg -i python2.7.....deb
Related
I would like to install older versions of python for use with virtual environments, ideally from source as these versions are readily available on the official python website python 3.6 here however I can't seem to find any decent instructions.
The link above has version 3.6 full link to the tar.gz here. It downloads, I move into to program files and unzip it with 7zip:
C:\Program Files\7-Zip\7z.exe e Python-3.6.9.tgz
Then unpack the tar file:
tar -xvzf Python-3.6.9
There is no python.exe file in the unpacked directory to add to my path?
Am I missing a build step perhaps?
I found some more instructions here - where there really should be good instructions!, git is installed and setup, as is vs-code. I ran :
PCBuild\build.bat
The file 'PCBuild\pcbuild.sln' appears to have been successfully produced. Now what? I run the test described here
rt.bat -q
And I get: The system cannot find the path specified
For some reason when I run build.bat, a lot of what is printed to the seems to be mentioning python 3.8 which is now the default install on my system, its as if this method is not even pointing to the right version of python.
Please note I am looking specifically for native python approaches to this - NOT conda approaches as it is incompatible with a number of things I am doing.
I've tried; another SO queation, another SO question, here, and here, also here.
Many install guides seem to show only how to install the latest version of python using the python installer, which doesn't seem to be able to be used for legacy versions of python.
Also pythons official site has a link at the bottom labelled ' tools for unpacking archive files' which one would presume would help you to unpack, possibly even install archive files, however the link just takes you back to the top of the page?
Any help would be much appreciated?
After installing the Nest Neural Simulator, I keep getting the following error when trying to run any of the example python files that came in the installation. I've tried re-installing Nest, Python, and using Anaconda, but no go.
Python error:
ImportError: No module named nest
Suggestions?
At https://nest-simulator.org/documentation you now find many different install instructions and how to solve the "ImportError: no module named nest" depends on the way you installed NEST.
System Python
The problem with the nest python module not being found is usually, that NEST is installed for a specific Python version and you can not load it from another. So while many OS still use Python 2.7 you may need to explicitly run
$ python3
>>> import nest
Additionally, if you have multiple Python 3.x versions installed, modules may still be installed for a different version and you have to explicitly start python with python3.6 or python3.8, etc.
Conda package
As #nosratullah-mohammadi already mentioned, if you have a Conda flavour installed, using the pre-built package is a very quick solution. The link in his post is unfortunately broken; this one should work, then go to "Installation" in the side bar.
$ conda create --name nest -c conda-forge python3 nest-simulator
$ conda activate nest
$ python # this should load the Python from the conda env
>>> import nest # this loads nest which is installed explicitly for that Python
From Source
For every install from source, be sure to have Python and other prerequisites installed before building NEST. Then you can create your temporary build directory (can be deleted afterwards) and configure with the flags you need.
cd somewhere
mkdir nest-build
cd nest-build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/install/path -Dwith-python=3 .../sources/of/nest-simulator
Replace somewhere, /install/path and .../sources/of/nest-simulator with the paths correct for your setup. (A popular choice when compiling from source in conjunction with Conda environments, for example, is to use -CMAKE_INSTALL_PREFIX=$CONDA_PREFIX, which installs NEST directly into the active environment. Conda is however in no way necessary for NEST.)
Add more -D... flags as you prefer. Possible flags you see with cmake -LA .../sources/of/nest-simulator, as pointed out here. You are probably interested in many of the with-xyz at the end. Check the aforementioned documentation for deatils.
Check that the paths and libraries reported in the Configuration Summary make sense (you may need to scroll up a bit to see). It could for example look something like this:
--------------------------------------------------------------------------------
NEST Configuration Summary
--------------------------------------------------------------------------------
[...]
Python bindings : Yes (Python 3.6.8: /home/yourname/miniconda3/envs/nest/bin/python3)
Includes : /home/yourname/miniconda3/envs/nest/include/python3.6m
Libraries : /home/yourname/miniconda3/envs/nest/lib/libpython3.6m.so
Cython bindings : Yes (Cython 0.27.3: /home/yourname/miniconda3/envs/nest/bin/cython)
[...]
--------------------------------------------------------------------------------
[...]
PyNEST will be installed to:
/home/yourname/miniconda3/envs/nest/lib/python3.6/site-packages
--------------------------------------------------------------------------------
In this example CMake configured everything for Python3.6 from my conda environment.
If you are satisfied with your settings and all the found Python versions match, run the usual
$ make # optionally with -j$(nproc)
$ make install
$ make installcheck
In case that works out fine you are done and can delete the build directory to free the space. Congratulations!
Also if things get too mixed up and it doesn't seem to do what you expect, it is sometimes useful to delete the build directory and start off clean.
there is a new method of installation added to other methods, wich is installing nest with conda package and it's in its beta version. but it works and it's really simple.
you can find the installation from here!
simply after install mini conda package run your terminal and type this :
conda create --name ENVNAME -c conda-forge nest-simulator python
then type :
conda activate ENVNAME
and you're good to go!
NEST now provide the solution to that problem and similar ones, by providing a script which automatically sets the relevant system variables:
If your operating system does not find the nest executable or Python
does not find the nest module, your path variables may not be set
correctly. This may also be the case if Python cannot load the nest
module due to missing or incompatible libraries. In this case, please
run
source </path/to/nest_install_dir>/bin/nest_vars.sh
to set the necessary environment variables. You may want to include
this line in your .bashrc file, so that the environment variables are
set automatically.
https://nest-simulator.readthedocs.io/en/latest/installation/linux_install.html
Turns out I needed to move the directory where I installed nest (Users/name/opt/nest) into a nest folder in the following directory in anaconda. Specifically, I moved the contents of the folder (from the nest installation):
/Users/name/opt/nest/lib/python2.7/site-packages/nest
Into this one:
/anaconda/lib/python2.7/site-packages/nest
Disclaimer: I could very well run into problems for not having copied all the contents of the Nest installation, but this little hack is helping me run example files now.
I am trying to install jedi-vim. I am doing this at work - so I have to use gVim in Windows. I have already read several other posts in this forum. This has somehow made me smarter but still does not solve my problem.
I did the following things:
installed Pathogen
cloned jedi vim from https://github.com/davidhalter/jedi-vim.git and copied it to the bundle/ folder in the vim-dir.
Now, when I open a *.py-file vim always tells me
jedi-vim requires vim compiled with +python
but ':version' tells me that it's compiled with +python/dyn and +python3/dyn.
So what is the problem?
Additional infos:
vim version: 7.4
When I use ctrl+space to autocomplete a python key word, it tells me:
Error detected while processing function jedi#completions: line 1: E492: Not an editor command: Python jedi_vim.completions()
Error detected while processing function jedi#completions: line 1: E492: Not an editor command: Python jedi_vim.completions()
Press ENTER or type command to continue
I'm not sure if your are still experiencing the same issue, but after looking around I found this blog post that solved the problem for me. Essentially, it's just about re-installing vim (don't delete any config files) and then reinstalling from the source at the vim mercurial repo with the right flags. There might be a shorter/simpler version of doing this, but after trying back and forth many solutions, this one was the only one that worked:
Compiling Vim with Python and Ruby support on Ubuntu
These are the steps:
Check if Vim is compiled with Python:
$ vim --version | ack '(python)'
Remove Vim version installed:
$ sudo apt-get remove vim-common vim-runtime
Install dependencies needed to compile Vim:
$ sudo apt-get build-dep vim
Clone Vim repository, compile it and install the new version:
$ hg clone https://vim.googlecode.com/hg/ vim
$ cd vim
$ ./configure --enable-pythoninterp
$ make
$ sudo make install
+python/dyn means that Python support isn't statically compiled it, it's loaded dynamically when needed at runtime.
This is described in the python-dynamic help section:
On MS-Windows the Python library can be loaded dynamically. The |:version| output then includes |+python/dyn|.
This means that Vim will search for the Python DLL file only when needed.
When you don't use the Python interface you don't need it, thus you can use
Vim without this DLL file.
To use the Python interface the Python DLL must be in your search path. In a console window type "path" to see what directories are used.
The name of the DLL must match the Python version Vim was compiled with.
Currently the name is "python24.dll". That is for Python 2.4. To know for
sure edit "gvim.exe" and search for "python\d*.dll\c".
(Don't worry about the 2.4 there; I just happened to find docs from a few years ago. Read the help in your own copy of vim—or, better, do what the last paragraph says.)
So, either you don't have Python, you have the wrong version of Python, it's not on your %PATH%, vim is searching for it incorrectly, or it's failing to load.
At that time the problem was another one. I mixed up the architectures for vim and python - I used vim64Bit, but pyhton for 32bit.
I repaired that already some time ago but the other day I had to restart my computer and do some microsoft-Updates.
Unfortunately my vim (7.4) was totally broken. I had to re-set my home-dir. Then at least my vimrc was accessible again, but still my jedi in vim does not work.
Python is available in vim but still jedi does not seem to load correctly.
When I type "len(" in the beginning of a .py-file, at the place where arguments should be explained there are some strange characters, similar to this:
==jedi=0, == (_object_*) ==jedi==
When I type "self.", it says "unknown function: pythoncomplete#Complete"
I think it's only a configuration-issue, because it worked before the reboot.
Jedi is installed systemwide (with pip). If I try to install it "again", pip says that jedi is already installed.
I would appreciate your help very much ;-)
I installed vim from source according to this link and it was succesful. But there is no python- support. I have installed python-dev and I've looked for the directory the Python config-file is in to set the right flag:
--with-python-config-dir=/usr/lib/python2.7-config
--enable-pythoninterp
I've installed vim from source two times, because the first time I forgot sth.
How can I get python-support now?
The installation guide you showed also states
You may need to add --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ to the configure call.
Have you tried this?
FYI, this is the contents of the directory on my Debian jessie (aka testing) x86_64.
$ ls /usr/lib/python2.7/config-x86_64-linux-gnu
Makefile Setup Setup.config Setup.local config.c config.c.in
install-sh* libpython2.7-pic.a libpython2.7.a libpython2.7.so# makesetup* python.o
i am trying to install pycairo 1.10.0 for use with my custom-build python 3.1. however,
sudo /flower/bin/easy_install-3.1 pycairo
fails with
XXX#XXXX:/adventures$ sudo /flower/bin/easy_install-3.1 pycairo
install_dir /flower/lib/python3.1/site-packages/
Searching for pycairo
Reading http://pypi.python.org/simple/pycairo/
Reading http://cairographics.org/pycairo
Best match: pycairo 1.10.0
Downloading http://cairographics.org/releases/pycairo-1.10.0.tar.bz2
Processing pycairo-1.10.0.tar.bz2
error: Couldn't find a setup script in /tmp/easy_install-zeG9HB/pycairo-1.10.0.tar.bz2
and indeed, there is no setup.py in the said download; instead, the INSTALL says:
Install Procedure
-----------------
$ ./waf --help # shows available waf options
$ ./waf configure # use --prefix and --libdir if necessary
# --prefix=/usr --libdir=/usr/lib64 for Fedora 64-bit
$ ./waf build
$ ./waf install
Use
$ python3 ./waf ...
if you have python2 and python3 installed, and the default is python 2.
Testing
-------
See test/README
i understand that as telling me that i should
sudo /flower/bin/python3.1 ./waf configure --prefix=/flower/pycairo/
or similar; however, this leads to the following error:
./options()
Setting top to : /tmp/pycairo-1.10.0
Setting out to : /tmp/pycairo-1.10.0/build_directory
./configure()
Checking for 'gcc' (c compiler) : ok
Checking for program python : /usr/bin/python
python executable '/usr/bin/python' different from sys.executable '/flower/bin/python3.1'
Checking for python version : (2, 6, 5, 'final', 0)
The python version is too old, expecting (3, 1, 0)
so i went down into the source code; there is seemingly no way to tell this waf thingie that the targetted python version is simply the one it runs on itself, so i fumbled around and got as far as this:
Checking for 'gcc' (c compiler) : ok
Checking for program python : /usr/bin/python
#############293 /flower/bin/python3.1
Checking for python version : (3, 1, 2, 'final', 0)
Checking for library python3.1 in LIBDIR : yes
Checking for program python3.1-config : not found
Checking for program python-config-3.1 : not found
Checking for header Python.h : Could not find the python development headers
Checking for [] : not found
The configuration failed
i do in fact have a file /flower/bin/python3.1-config so i don't get it. the python code that does all this is rather hard to handle.
any suggestions how to go on? is there a *.deb or similar ready for pycairo + python 3? couldn't find any.
By looking at the python.py file in that subdir I decided to try setting an environment var before executing the waf thru python3:
export PYTHON="python3"
And then the install mysteriously succeeded...
I'm using Ubuntu Karmic, but installing with python2.7 compiled from source, so this is a work around I found in my case. I though it might be helpful, but please use caution.
I found some discussion threads that has similar installation problems here
Although it's not the same python version, there are some flags which you can set for waf.
I got past that Python.h part after using the following command
LDFLAGS="-lm -ldl -lutil" ./waf configure
As I have compiled from source python2.7, I need to reroute the paths with CFLAGS.
The final command looks like this:
CFLAGS="-l/usr/local/include/python2.7 -l/usr/local/bin" LDFLAGS="-lm -ldl -lutil" ./waf configure
I have no idea how the LDFLAGS work, so use with caution.
Alternatively (dangerous method), if you don't want to set the CFLAGS, I did do some symbolic-re-linking in the /local/bin of python to my python2.7, same with python-config to python2.7-config (if you installed from package manager, you might not need to do this)
This is clearly a bug in the pycairo installer, where it tries to figure out where the Python exe is (when what it should do is to simply use the Python exe that it is run with).
I tried to find it, but this code is using its own completely custom build system (it's not onvious why) and the code is laid out in a very weird way, astonishingly with major parts of the code hidden(!) in a directory called .waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6 and written in some of the most unreadable Python code I've ever seen. As such it would take me hours to understand this code and help you with what probably is a trivial bug.
If you really need this library I suggest you contact the author and ask him nicely if he can fix the bug.