Skip to content
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

pycppad in python3.5 #6

Open
al00014 opened this issue Nov 21, 2016 · 8 comments
Open

pycppad in python3.5 #6

al00014 opened this issue Nov 21, 2016 · 8 comments

Comments

@al00014
Copy link

al00014 commented Nov 21, 2016

Has anyone succeeded in importing the pycppad in python 3.5? I know I have to deal with CppAD and boost first. I was successful in using cmake to build the boost library but then during setup of pycppad, I encountered "AttributeError: 'NoneType' object has no attribute 'lstrip'".

I am wondering if it's true that pycppad could only be used in python2.7?

Much appreciated.

@bradbell
Copy link
Collaborator

I agree that it would be good the get pycppad to work with python3. Unfortunately, I currently have too many open source projects and hence am not working on it much right now. I would be willing to help if you would like to try and do this.

Just to see what goes wrong, I tried to build pycppad with the current master version of CppAD on github; see
http://www.coin-or.org/CppAD/Doc/download.htm
you would probably get the same result using
http://www.coin-or.org/download/source/CppAD/cppad-20150000.9.gpl.tgz

Step 1:
I changed the first line of setup.py to:
#!/usr/bin/env python3

Step 2:
I executed the command:
pycppad.git>./setup.py build_ext --inplace --debug --undef NDEBUG

Result:
I got the following error:
pycppad/vector.cpp: In function ‘void pycppad::vector_avoid_warning_that_import_array_not_used()’:
/usr/lib64/python3.4/site-packages/numpy/core/include/numpy/__multiarray_api.h:1708:35: error: return-statement with a value, in function returning 'void' [-fpermissive]
#define NUMPY_IMPORT_ARRAY_RETVAL NULL

Remark:
I think that numpy has changed its API between python2 and python3 and one needs to do work to adapt to these changes.

@al00014
Copy link
Author

al00014 commented Nov 22, 2016

Hey Bradbell! Thank you for your help!
Actually this is what I get when I ran the line "python setup.py build_ext --compiler=mingw32 install",
(C:\Users\44700\Anaconda3) C:\Users\44700\pycppad>python setup.py build_ext --compiler=mingw32 install
running build_ext
Looking for python35.dll
Traceback (most recent call last):
File "setup.py", line 87, in
data_files = package_data_files
File "C:\Users\44700\Anaconda3\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Users\44700\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Users\44700\Anaconda3\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Users\44700\Anaconda3\lib\distutils\command\build_ext.py", line 307, in run
force=self.force)
File "C:\Users\44700\Anaconda3\Lib\site-packages\numpy\distutils\ccompiler.py", line 596, in new_compiler
compiler = klass(None, dry_run, force)
File "C:\Users\44700\Anaconda3\Lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 96, in init
msvcr_success = build_msvcr_library()
File "C:\Users\44700\Anaconda3\Lib\site-packages\numpy\distutils\mingw32ccompiler.py", line 329, in build_msvcr_librar
y
if int(msvcr_name.lstrip('msvcr')) < 80:
AttributeError: 'NoneType' object has no attribute 'lstrip'

I am using a windows 10 device, I install mingw manager and installed gcc+,pthreads from the manager. I then use the cmake GUI to build the cppad file in our local files.

The GUI suggested both 'Configuring done' and 'Generating done'. But it also said 'Could not find boost multi-threading library' and I don't know if this would have influence on the building process.

Lastly, I was able to ran ->boostrap.bat mingw and ->b2.exe variant=release link=shared threading=multi python. This got me a bunch of files in the location 'C:\Python\boost_1_62_0\bin.v2'.

I followed this tutorial http://list.coin-or.org/pipermail/cppad/2013q2/000309.html but I did not have any success yet.

I know it'd be too much for you to handle since it's time-consuming to debug or to replicate the problems. But I do wish to get some hints from you.

Thanks a lot.

@bradbell
Copy link
Collaborator

I have a windows 10 machine available. Perhaps it would help if I
reproduce your environment. What steps did you go through to install
mingw ? For example, did you use the mingw-get-setup.exe program ?

On 11/22/2016 06:31 AM, al00014 wrote:

Hey Bradbell! Thank you for your help!

... snip ...

I am using a windows 10 device, I install mingw manager and installed
gcc+,pthreads from the manager. I then use the cmake GUI to build the
cppad file in our local files.

... snip ...

@al00014
Copy link
Author

al00014 commented Nov 23, 2016

Yes indeed I use mingw-get-setup.exe program and install it in the location 'C:\Python\MinGW', I then put the 'C:\Python\MinGW\bin' in the PATH environment variable via 'Advanced system settings' in the computer.

Then I located the boost file 'C:\Python\boost_1_62_0' and ran the line 'bootstrap.bat mingw'. After this, I got b2.exe in the 'C:\Python\boost_1_62_0' and changed project-config.jam to target my Anaconda3.

Then I built the library with command 'b2.exe variant=release link=shared threading=multi python'.

I was able to locate a dll file in 'C:\Python\boost_1_62_0\bin.v2\libs\python\build\gcc-mingw-4.7.0\release\threading-multi'. And I changed the setup.py script in pycppad to match the dll and the location.

I then ran Cmake-GUI and it suggested that it could find the boost 1.6 and I can get the generation process done. But it also suggested that

pthread library path = pthread_lib_path-NOTFOUND
Could not find boost multi-threading library

Therefore, I am so confused.

PS. I ran the above procedures in the surface pro win 10 device. I was trying to replicate the procedures in my other win10 device but it seems that I could not get the boost library setup properly. This may well be another question though...

Much appreciated~~~

@al00014
Copy link
Author

al00014 commented Nov 23, 2016

To add to the topics, I seem to discover the reasons why my surface ran bootstrap.bat mingw successfully while my other windows machine won't run properly. I also use R programming and installed Rtools which come with mingw. During the installation, Rtools add 'Rtools\bin' to the path for the system variables. I don't know if Rtools and MinGW could be in conflict with each other....

@bradbell
Copy link
Collaborator

On 11/22/2016 07:12 PM, al00014 wrote:

Yes indeed I use mingw-get-setup.exe program and install it in the
location 'C:\Python\MinGW', I then put the 'C:\Python\MinGW\bin' in
the PATH e

... snip ...

I installed the mingw installer and notice that it refers to its
packages as mingw32-*. Does this mean I got the 32 bit version by
mistake; i.e., is there a 64 bit version ?

@al00014
Copy link
Author

al00014 commented Nov 23, 2016

I think there is a 64 bit version, but the software is provided by http://tdm-gcc.tdragon.net/download. Also, when I install Rtools, I got both 32 and 64bit version mingw. I think the gcc from MinGW/bin and Rtools/mingw_32 and Rtools/mingw_64 are all messed up together...

@bradbell
Copy link
Collaborator

On 11/23/2016 06:53 AM, al00014 wrote:

I think there is a 64 bit version, but the software is provided by
http://tdm-gcc.tdragon.net/download. Also, when I install Rtools, I
got both 32 and 64bit version mingw. I think the gcc from MinGW/bin
and Rtools/mingw_32 and Rtools/mingw_64 are all messed up together...


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#6 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AACTkQwlbghOlHGTy0bvAdFGpZRGSJ8Xks5rBEU_gaJpZM4K3yJL.

Please email me directly at my seanet address, so we can take our
discussion to personal e-mail until we figure out what setup we are
using. If you do not know my e-mail, try searching for Brad Bell Math on
google.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants