For test purposes,
I tried to install Blender as a Python module in a virtual environment with Python 3.7 to be sure that i can use bpy.
I follow this page for the installation (https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule)
I would like at the end, when I wrote a Python script who used blender command to be able to run outside Blender software and to get information when my script finish
So I have multiples questions:
I don't really understand this line of command for Windows and how I can adapt to my virtual environment :
xcopy /E bin\2.81 C:\Python37\2.81
I can't use 'import bpy' command even when I successfully do pip install bpy in the command line ?
For my final goal project, I'm afraid that it's impossible to do because I couldn't find examples or questions related to my project.
Can someone could explain a little if it's possible or interesting to use Blender externally ?
Related
I am veryy new in coding and wanted to get into it. So I downloaded VS code. But I tried to run a very simple python command and it does not let me. See the picture below.
Visual Studio code is not an IDE, it is a code editor, which means you cannot run nor debug code naturally, for that you would need to run it on the windows terminal, or install extra packages and dependencies. If youre new and just want to learn Python, i suggest starting with a python IDE like the standard one provided or something more advanced like Pycharm, and if you want to program on VsCode and in multiple languages, search some tutorials about how to compile and run code on the windows terminal.
Provide more details about how you installed python from Microsoft Store, from anaconda or via its official page https://www.python.org/downloads/. Try running
python --version
or
python3 --version
If so you can run a python file from terminal. Assuming my file is called test.py
python test.py
I'm writing a CLI application using the python click library, and I want users of my CLI to have shell autocompletion out of the box. Precisely, I want my users to install my CLI using pip install my-cli and after that they would have autocompletion already without having to source any shell file or install any other package.
I already implemented the autocompletion script as shown in the official docs of the click library and automated the autocompletion installation in setup.py. I did it following these instructions
However, in this case, my users would have to install my-cli and then re-source the shell script file (e.g .bashrc for bash).
Precisely, this is what is happening:
open the terminal
run pip install my-cli (I automated installing the completion script here)
users do not have autocompletion yet. Therefore, they should open a new terminal or run source .bashrc (this is the step that I want to automate, if possible)
After that, autocompletion works fine
I don't know if this is possible in my case. I know that I can't source a shell script using python since the python subprocess module will spawn a subprocess and the environment changes will not apply on the current process in this case (correct me if I'm wrong).
On the other way, some packages like git and docker provide autocompletion automatically after installing them. Last time I installed docker and then run docker <Tab> <Tab> I already got a list of the subcommands that I can use. So it would be interesting to know how to achieve this using python.
Interestingly, some other python CLI frameworks like typer provides a way to automatically install autocompletion using a subcommand. However, after running the install command, it shows a message that you should re-source the bash script or open a new terminal in order to get autocompletion, which makes me wonder if it's possible to automate this step, because I'm sure they would have done it if that is the case.
I am looking to schedule my python script runs with jenkins. The issue is, my scripts use a lot of libs like pandas etc that are installed on my mac terminal.
Is there a way to allow Jenkins to pick up these modules (or run the scripts as if it was terminal)? Also is there a way to run Python3 in jenkins?
I have already configured Jenkins to execute from custom workspace and have tried both shell and plugin executions.
The answer is yes, but it is detailed so I can only give you high level steps here. Jenkins can execute command line statements, and python modules can be run from the command line.
I would start by using the begins library to create a python file to run from the command line with arguments. Get it working on your local machine that way.
You will want to use either virtualenv or venv, and do all your pip installs using that virtual environment. Then you can copy the virtual environment to your Jenkins machine, or create a new one. Look into the freeze tool.
When calling your python from jenkins, you must first activate your virtual environment just as if you were working on it yourself.
You have a lot of research to do, but is very doable. I can help with follow up questions if needed.
I am new to python, and trying to set up my environment to start python builds. I am using Atom as an editor. What all should I do? Through some online tutorials, I got these recommendations, but I still get some errors when I open up a python project
Installed python
Installed pip
In Atom, installed the following packages:
linter
linter-flake8
linter-ui-default
busy-signal
intentions
I get this error:
Flake8 crashed!
linter-flake8:: Flake8 threw an error related to:
Failed to spawn command flake8. Make sure flake8 is installed and on your PATH
Please check Atom's Console for more details
Setting up Atom as an IDE might not be in your best interests to learn python.
Python is a scripting language. Pip is a package manager. Atom is a code editor. All you need now is the command line to bring all of them together.
Open your terminal and cd (change directory) to the location where your file is saved. Run it using the command "python file_name.py" on the terminal.
If you have imported a package in your script that isn't installed on your machine, simply execute "pip install package_name" on the terminal.
Happy programming!
PRO Tips :: If you learn to use vi or vim you can remove Atom from your list of tools. Also, might be a good idea to learn about virtualenv to keep your system sane.
The error already tells you what is wrong.
As per the documentation for linter-flake8: To use this plugin flake8 will need to be installed on your system.
With regard to installing software, it is generally helpful to put your operating system in the tags. Installing stuff on ms-windows is different from Linux or other UNIX-like operating systems.
search for script package and install it.
You can run the code by using ctrl+shift+b
The good thing about script package is you can run any code e.g. filename.c, filename.py etc.
I am trying to install Sublime Text 2 on my linux machine and I cannot figure out how to run the python script to install it. I am fairly new to linux and never programmed in python before. I am trying to run the python script PackageSetup.py using ./PackageSetup.py but i get the error:
bash: ./PackageSetup.py: python: bad interpreter: No such file or directory
not sure what I have to do. I have python on my machine. I can tell cause running 'python' puts me in the console.
For all I know this kind of issue can occur if you have a misspelling or mistake in the shebang. I see two ways to solve this issue: you can try to invoke PackageSetup.py via python, like python PackageSetup.py or you can open PackageSetup.py and try to find an issue in the shebang, maybe it needs to be a full path to python interpreter like /usr/bin/python not just python.
BTW, why don't you try to install it via some kind of package manager - there is a repo for debian-based distros, and I'm pretty sure that there have to be repositories for other distributives.