How to use the blenderpy module from Blender in (Anaconda) Spyder - python

I've tried to install the module bpy (blenderpy) to be able to run python-scripts for Blender directly from Spyder IDE with Python 3.8.5. However, I can't seem to find a good solution for this.
I've tried to follow this wiki on Github to use a build provided for bpy version 2.82. I installed every required program and tried to install bpy with !pip install bpy --no-binary :all: in the Spyder-console, like it was suggested in the wiki. Unfortunately, bpy version 2.82 is not compatible with Windows Python 3.8.5:
in build_cmake
raise Exception(f"{VERSION} bpy is not compatible with "
Exception: 2.82 bpy is not compatible with Windows Python 3.8.5 (default, Sep 3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] 64bit [...]
Otherwise the installation of bpy would probably have worked.
My question is now: Is there a more recent build for bpy which can be installed with pip and is compatible with (Anaconda) Spyder python 3.8.5? If not, which Anaconda-distribution of Python do I need to install in order to be compatible with bpy 2.82? How could you manually add modules (like bpy) to your Spyder IDE that aren't available in the Anaconda-Distribution of Python and can't be installed via anaconda.org?

Related

Failure import pygame in IDE on python 3.8.3

I have downloaded pygame:
C:\>pip3 install pygame --user
Requirement already satisfied: pygame in c:\users\mpenn\appdata\local\programs\python\python38-32\lib\site-packages (2.0.0.dev8)
And I have python 3.8.3:
C:\>py
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
But when I try to import pygame in my "Wing Personal 7" IDE, I get the error:
builtins.ModuleNotFoundError: No module named 'pygame'
This has only started happening since I updated python to 3.8.3 yesterday.
make sure your python directory(the one where all the modules are stored) is added to the PATH variable. There are already many tutorials to do so:
How do I add Python to the Windows PATH
or if that doesn't work for you, google is your best friend.
In Wing, you need to change python executable to the python version you are using. python executable is found in Project, Project Properties...
Make sure that pip is up to date. Try running:
pip3 install --upgrade pip

Which version of pygame is right for me?

I am trying to install pygame. But I am not sure which version is appropriate for me.
I am working on a Windows 10 AMD64 PC.
The version of Python that is installed, shows-
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32
on typing python into the command prompt.
I can find the packages here and here.
But there are only items listed such as-
Download repository
pygame-1.9.2-cp27-cp27m-win32.whl
pygame-1.9.2-cp34-cp34m-win32.whl
pygame-1.9.2-cp35-cp35m-win32.whl
pygame-1.9.2-cp27-cp27m-win_amd64.whl
pygame-1.9.2-cp34-cp34m-win_amd64.whl
pygame-1.9.2-cp35-cp35m-win_amd64.whl
Now I have no idea which one of these is to get.
And, what are the differences among cp27, cp34 and cp35?
Please help me choose my version.
normally you should just type following command
py -m pip install pygame
On non windows system you just type
pip install pygame
and the correct file will be downloaded and installed.
The pip module will consult https://pypi.org to indentify the versions available and choses normally the right one

Python 3.6.5_1 installed in incorrect location (Mac OS)

I install python 3.6.5_1 using
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.r
and get
Warning: python 3.6.5_1 is already installed
The currently linked version is 3.7.3
You can use brew switch python 3.6.5_1 to link this version.
I use brew switch python 3.6.5_1 and get
Cleaning /usr/local/Cellar/python/3.6.5_1
Cleaning /usr/local/Cellar/python/3.7.3
4 links created for /usr/local/Cellar/python/3.6.5_1
Typing which python3, there is no output, which python gives
/usr/local/bin/python
and typing python3 gives
-bash: /usr/local/bin/python3: No such file or directory
typing python gives
Python 2.7.15 (default, Nov 27 2018, 21:24:58)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
How do I make sure that the installed python3.6.5_1 is installed at correct location and is the one referred to by python3?
Extra background :
I have been working with OpenCV for around 5 months now, following this installation guide for installing all requirements including python3.6. I was using this version of brew's python instead of mac's one. Recently I had to install FFmpeg, some errors came up, unwittingly I did something (I don't remember, probably unlinked python) and then I wasn't able to install FFmpeg anyway but also this destroyed my workspace. Right now I keep getting the following error everytime I open up terminal:
-bash: /usr/local/bin/python3: No such file or directory
virtualenvwrapper.sh: There was a problem running the initialization hooks.
If Python could not import the module virtualenvwrapper.hook_loader,
check that virtualenvwrapper has been installed for
VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3 and that PATH is
set properly.
I tried brew install python3 and that solves the above warning for virtualenvwrapper. But it installs python3.7.3, whereas I need python3.6 for tensor flow etc.

rpy2 module is invisible from python 2.7 on Mac 10.6.8

I am a bit of a noob on Mac and my python installation is refusing to acknowledge the existence of the rpy2 module on my mac. It looks like it only sees it as a Python 2.6 module. How do I make it visible in 2.7 ? Do I need to downgrade my python ? If so, how ? On the RPy2 web page (http://rpy.sourceforge.net/rpy2_download.html) Python 2.6 is recommended. Thanks!
mayumi#MAYUMI-iMac~:/ python --version
Python 2.7.6
mayumi#MAYUMI-iMac~:/ pip install rpy2
Requirement already satisfied (use --upgrade to upgrade): rpy2 in /Library/Python/2.6/site-packages/rpy2-2.3.8-py2.6-macosx-10.6-universal.egg
Cleaning up...
mayumi#MAYUMI-iMac~:/ python
Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpy2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named rpy2
>>>
I also found it is difficult to successfully install rpy2 in OSX machines. Sometime it works, sometimes it doesn't, which is very annoying. I eventually settled with Anaconda Python distribution from https://store.continuum.io/cshop/anaconda/ to save all the troubles. Installing rpy2 never fails since the switch.
The default installation of Anaconda does not included rpy2, so you want to run the installation command, from Anaconda folder, bin subfolder
conda install rpy2
Depends on the version, you may get a bunch of warnings. Just ignore them.
Then rpy2 just works! Of course, only under the Anaconda python, not the other python version you may have installed on your machine.
You can run a few test to make sure rpy2 works, following this example: http://nbviewer.ipython.org/urls/raw.github.com/ipython/ipython/3607712653c66d63e0d7f13f073bde8c0f209ba8/docs/examples/notebooks/rmagic_extension.ipynb
bash commands, run in the folder /Users/YOUR_USER_NAME/anaconda/bin/:
user-Mac-Pro:bin user$ conda install rpy2
and it says:
Conda package not available for rpy2, attempting to install via pip
Downloading/unpacking rpy2
Downloading rpy2-2.3.8.tar.gz (185kB): 185kB downloaded
Running setup.py egg_info for package rpy2
If you don't have R installed it will complain with a few warnings and fetch R for you. Then there may be some other depreciation warnings dependents on what you have installed.
(I am not associated with Continuum in any way)
You can see that pip installed to the site-packages to python 2.6 since you installed pip with python 2.6 it will default to use that library.
rpy2 in /Library/Python/**2.6**/site-packages/rpy2-2.3.8-py2.6-macosx-10.6-universal.egg
You can redirect pip installation location or use easy_install2.7 which should be around in /usr/local/bin/

how to install Matplotlib on Cygwin?

I'm trying to install Matplotlib 1.0.1 version on latest Cygwin. In the processing, there is a weird fork error cannot be solved. I googled similar questions and found that it might be solved by manually running gcc/g++ with matplotlib 0.98.5.2 : http://innuendopoly.org/arch/matplotlib-cygwin. But it doesn't work under 1.0.1 version. Does anybody encounter the same problem?
Here are instructions for how to install matplotlib 1.1.0 on Cygwin
http://berlinbrowndev.blogspot.com/2012/01/python-matplotlib-plotting-setup-for.html
Python matplotlib plotting setup for cygwin
Matplotlib is a popular python library for generating plot graphics. It works with cygwin win32 but some non-intuitive steps are required.
Install cygwin:
CYGWIN_NT-5.1 1.7.9(0.237/5/3) 2011-03-29 10:10 i686 Cygwin
I am using cygwin with setup 2.7.3
Install python through cygwin:
This document describes installing python and matplot with cygwin. For most windows users and cygwin users, normally you would use the external python executable. I tend to prefer all of my script oriented applications running through cygwin including python.
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
In the cygwin setup.exe installer, install:
The freetype libs, python-gtk, python-tk, libpng
gcc
Download matplotlib from sourceforge:
I am using the latest version matplotlib-1.1.0 as of 1/2012.
Download and extract the matplotlib tarball
Issues with standard python install and cygwin:
The typical 'python setup.py install' will not work with cygwin. You need to modify a configuration file and run some other additional commands.
In the root directory of the expanded matplotlib directory, copy the setup.cfg.template configuration file to setup.cfg. Edit setup.cfg.
Around line 70 in the file is a commented line, uncomment the line such that you have:
tkagg = False
Run install and watch it fail
Try running 'python setup.py install'
It should fail with an error like the following:
2 [main] python 2796 C:\cygwin\bin\python.exe: *** fatal error - unable to remap C:\cygwin\bin\cyggfortran-3.dll to same address as parent: 0x18660000 != 0x69780000
Stack trace:
Run the rebase command OUTSIDE OF THE TYPICAL CYGWIN ENV
Exit cygwin and close all cygwin instances including the one you are working with. You won't be using the typical cygwin prompt for the next command.
In windows explorer, open the cmd.exe or windows command
You will need to run rebaseall. First, shut down any long running processes like sshd, close all Cygwin prompts and so on.
Type the following commands:
cd \cygwin\bin
ash
PATH=. rebaseall -v
...
And you should get several lines of output.
Run install and watch it succeed
Try running 'python setup.py install' command again in the matplotlib directory
Running Example Program:
# python
Python 2.6.5 (r265:79063, Jun 12 2010, 17:07:01)
[GCC 4.3.4 20090804 (release) 1] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
import matplotlib.pyplot as pyplot
pyplot.pie([1,2,3])
pyplot.show()
pyplot.savefig('f.png')
pyplot.savefig('x.eps')
These steps taken from www.scivision.co worked for me:
Run Cygwin setup: (For some reason the original command posted in the source link did not work for me)
install packages: (most of these you may already have)
pkg-config
ghostscript
libfreetype-devel
libpng-devel
libgtk2.0-devel
gcc-g++
git
openbox
python3-numpy
python3-pyqt5
python3-devel
Then from Cygwin Terminal:
easy_install-3.6 pip
pip install --upgrade six
pip install matplotlib
Then tested from python console:
import matplotlib
matplotlib.__version__
Installation worked for me as described by Felix above.
But to use matplotlib you need to start the Xserver from Cygwin first:
startxwin
and then start your script.

Categories

Resources