Sublime Text 3 ; Conda Environment - anaconda

I am extremely new to creating environments, and i'm having issues setting the directory path to the correct location. I have Anaconda install on this machine.
By default, it looks like it is going here:
[Errno 2] No such file or directory:
'/Users/examplename/anaconda3/bin/python' [cmd:
['/Users/examplename/anaconda3/bin/python', '-u',
'/Users/examplename/Desktop/python_work/test_pyenvironment.py']] [dir:
/Users/examplename/Desktop/python_work] [path:
/usr/bin:/bin:/usr/sbin:/sbin]
When my anaconda file location is actually in:
'MacintoshHD/anaconda3/bin/python'
Does anyone know how I can change where Sublime Text is looking, when trying to find this root folder? I'm not too sure about the PATH either, 'usr/bin:/bin:etc.' doesn't seem right?

Considering you are using your main anaconda env with pandas installed, you need to set a build system for your anaconda env. Like in this answer and mine you need to go to Tools ▶ Build System ▶ New Build System and set your custom build system:
{
"shell_cmd": "~/anaconda3/bin/python -u $file",
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python",
}
And to use this custom build you have to select either Tools ▶ Build System ▶ Automatic or Tools ▶ Build System ▶ <your-custom-build-system-name> before building your code and/or to satisfy the Anaconda package for sublime.

Related

Jupyter lab build fail after installing plotly extension

Plotly figures are not rendered/displayed in jupyterlab. I therefore tried to install the extension jupyter labextension install #jupyter-widgets/jupyterlab-manager jupyterlab-plotly. Afterwards I was asked to run the jupyter lab build and this failed. I have no idea where the problem is.
Install info:
I installed a venv with pyenv running python 3.8.5.
jupyter --version
jupyter core : 4.7.1
jupyter-notebook : 6.4.0
qtconsole : not installed
ipython : 7.25.0
ipykernel : 6.0.3
jupyter client : 6.1.12
jupyter lab : 3.0.12
nbconvert : 6.1.0
ipywidgets : 7.6.3
nbformat : 5.1.3
traitlets : 5.0.5
npm --version
7.11.2
node --version
v16.1.0
I am restricted to use WSL1 because of company requirements.
I’ll post below the command outputs for
jupyter labextension list
jupyter lab build
cat /tmp/jupyterlab-debug-5vr2zquq.log
jupyter labextension install #jupyter-widgets/jupyterlab-manager --minimize=False
Any advice would be appreciated. I have no idea how to fix this.
Thanks
❯ jupyter labextension list
JupyterLab v3.0.16
/home/bebop/.local/share/jupyter/labextensions
#jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
/mnt/s/dokumente/Privat/neue_fische/ot/ot-sopra_steria/.venv/share/jupyter/labextensions
jupyterlab-plotly v5.1.0 enabled OK
Other labextensions (built into JupyterLab)
app dir: /mnt/s/dokumente/Privat/neue_fische/ot/ot-sopra_steria/.venv/share/jupyter/lab
plotlywidget v4.14.3 enabled OK
Build recommended, please run jupyter lab build:
plotlywidget needs to be included in build
❯ jupyter lab build
[LabBuildApp] JupyterLab 3.0.16
[LabBuildApp] Building in /mnt/s/dokumente/Privat/path/.venv/share/jupyter/lab
[LabBuildApp] Building jupyterlab assets (production, minimized)
Build failed.
Troubleshooting: If the build failed due to an out-of-memory error, you
may be able to fix it by disabling the dev_build and/or minimize options.
If you are building via the jupyter lab build command, you can disable
these options like so:
jupyter lab build --dev-build=False --minimize=False
You can also disable these options for all JupyterLab builds by adding these
lines to a Jupyter config file named jupyter_config.py:
c.LabBuildApp.minimize = False
c.LabBuildApp.dev_build = False
If you don’t already have a jupyter_config.py file, you can create one by
adding a blank file of that name to any of the Jupyter config directories.
The config directories can be listed by running:
jupyter --paths
Explanation:
dev-build: This option controls whether a dev or a more streamlined
production build is used. This option will default to False (i.e., the
production build) for most users. However, if you have any labextensions
installed from local files, this option will instead default to True.
Explicitly setting dev-build to False will ensure that the production
build is used in all circumstances.
minimize: This option controls whether your JS bundle is minified
during the Webpack build, which helps to improve JupyterLab’s overall
performance. However, the minifier plugin used by Webpack is very memory
intensive, so turning it off may help the build finish successfully in
low-memory environments.
An error occured.
shutil.Error: [(’/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/staging/templates’, ‘/mnt/s/dokumente/Privat/path/.venv/share/jupyter/lab/staging/templates’, “[Errno 13] Permission denied: ‘/mnt/s/dokumente/Privat/path/.venv/share/jupyter/lab/staging/templates’”)]
See the log file for details: /tmp/jupyterlab-debug-5vr2zquq.log
❯ cat /tmp/jupyterlab-debug-5vr2zquq.log
[LabBuildApp] Building in /mnt/s/dokumente/Privat/path/.venv/share/jupyter/lab
[LabBuildApp] Node v16.1.0
[LabBuildApp] Yarn configuration loaded.
[LabBuildApp] Building jupyterlab assets (production, minimized)
[LabBuildApp] Traceback (most recent call last):
[LabBuildApp] File “/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/debuglog.py”, line 47, in debug_logging
yield
[LabBuildApp] File “/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/labapp.py”, line 166, in start
raise e
[LabBuildApp] File “/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/labapp.py”, line 162, in start
build(name=self.name, version=self.version,
[LabBuildApp] File “/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/commands.py”, line 469, in build
return handler.build(name=name, version=version, static_url=static_url,
[LabBuildApp] File “/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/commands.py”, line 657, in build
self._populate_staging(
[LabBuildApp] File “/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/commands.py”, line 1180, in _populate_staging
shutil.copytree(pjoin(HERE, ‘staging’, ‘templates’), templates)
[LabBuildApp] File “/home/bebop/.pyenv/versions/3.8.5/lib/python3.8/shutil.py”, line 554, in copytree
return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
[LabBuildApp] File “/home/bebop/.pyenv/versions/3.8.5/lib/python3.8/shutil.py”, line 510, in _copytree
raise Error(errors)
[LabBuildApp] shutil.Error: [(’/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/staging/templates’, ‘/mnt/s/dokumente/Privatpath/.venv/share/jupyter/lab/staging/templates’, “[Errno 13] Permission denied: ‘/mnt/s/dokumente/Privat/path/.venv/share/jupyter/lab/staging/templates’”)]
[LabBuildApp] Exiting application: JupyterLab
❯ jupyter labextension install #jupyter-widgets/jupyterlab-manager --minimize=False
Building jupyterlab assets (production, not minimized)
An error occured.
shutil.Error: [(’/mnt/s/dokumente/Privat/path/.venv/lib/python3.8/site-packages/jupyterlab/staging/templates’, ‘/mnt/s/dokumente/path/.venv/share/jupyter/lab/staging/templates’, “[Errno 13] Permission denied: ‘/mnt/s/dokumente/Privat/path/.venv/share/jupyter/lab/staging/templates’”)]
You should not need to install the extension from source. JupyterLab 3.0 introduced prebuilt extensions system that allows users to install extensions from pip (and conda) without the need for the build step making all the trouble of troubleshooting failed builds disappear. It seems that you used an old set of instructions for installing plotly, as plotly 5.0+ supports prebuilt extensions for JupyterLab. First uninstall the source extensions that you just installed (non of those are needed):
jupyter labextension uninstall #jupyter-widgets/jupyterlab-manager jupyterlab-plotly plotlywidget
Optional: verify list of extensions with:
jupyter labextension list
Then install a new plotly version with pip or conda:
pip install "plotly>=5" "ipywidgets>=7.6"
# or, if using conda:
# conda install -c conda "plotly>=5"
# conda install "ipywidgets>=7.6"
Both widget and renderer are included, so no need to install plotlywidget separately.
Check list of extensions again:
jupyter labextension list
You should now see lines with:
jupyterlab-plotly v5.1.0 enabled OK
#jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
(the version may be newer in the future of course).

cannot run scons - unable to find files

So I've installed scons via Anaconda's conda install scons under Windows 10 (Python 3.6) and could not execute it via the command line so I've added C:\Users\D\Anaconda3\envs\py36\Scripts\ to my Path (even tough C:\Users\Dominik\Anaconda3 was already in there).
Now I can execute it in the Powershell, but I get an error, because it is unable find engine files:
scons
SCons import failed. Unable to find engine files in:
C:\Users\D\Anaconda3\envs\py36\Scripts\..\engine
C:\Users\D\Anaconda3\envs\py36\Scripts\scons-local-3.0.1
C:\Users\D\Anaconda3\envs\py36\Scripts\scons-local
C:\Users\D\Anaconda3\scons-3.0.1
C:\Users\D\Anaconda3\Lib\site-packages\scons-3.0.1
C:\Users\D\Anaconda3\scons
C:\Users\D\Anaconda3\Lib\site-packages\scons
Traceback (most recent call last):
File "C:\Users\D\Anaconda3\envs\py36\Scripts\scons.py", line 192, in <module>
import SCons.Script
ImportError: No module named 'SCons'
Does someone know how to further investigate/fix this problem?
I found it thanks to nekomatic.
If you use the anaconda prompt (with the correct environment activated or in my case the correct shortcut leading to anaconda prompt in that environment), scons runs just fine.
See this link explaining how anaconda uses the path on windows and whats the advantage of using the anaconda prompt (mainly it dynamically manages PATH correctly for that session only with full knowledge of conda environments).

Sublime 3: Strange output using build system for Python3

I'm on OS X and I'm trying to get python3 working in sublime. I installed python3 via homebrew and I installed numpy for both python and python3 using pip. In order to be able to build python3 I added the following build file for sublime:
{
"path": "/usr/local/Cellar/python3/3.4.2_1/bin",
"cmd": ["python3", "-u", "$file"],
"env":{},
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.python"
}
Finally I'm trying out the build system on the following test file:
#test.py
import numpy
def square(x):
return x * x
if __name__ == '__main__':
print("test: square(42) ==", square(42))
If I build this with the build system set to python (which uses the OS X default version of python 2.7.8) then I get the following (correct) output when I build in sublime:
('test: square(42) ==', 1764)
[Finished in 0.1s]
However, if I set my build system to build with python3 I get the following strange results when I build in sublime:
sh: sysctl: command not found
sh: grep: command not found
sh: sw_vers: command not found
sh: grep: command not found
test: square(42) == 1764
[Finished in 0.1s]
I still get the correct output but also get a bunch of command not found. What's even stranger, if I save this script and run it directly from the terminal using python test.py for python 2.7.8 or using python3 test.py for python 3 I get the correct output in the terminal. Additionally, if I remove import numpy from test.py I no longer get any of the command not found errors in my sublime output.
This problem seems to only show up in sublime using python3 with the above build file and only when I'm trying to import a library installed with pip. If I change the above import in test.py to sys then it will build in sublime without any error messages.
I think I have an answer for you.
Your path variable
"path": "/usr/local/Cellar/python3/3.4.2_1/bin",
needs to append to the existing $PATH. Simply replacing that line in your build file with
"path": "$PATH:/usr/local/Cellar/python3/3.4.2_1/bin",
fixed it for me.

Build R source code from windows

C:\Work\R contains the R-3.1.1.tar.gz file
I have build R source(R-3.1.1) in windows 8 from the following commands
cd C:\Work\R
tar --no-same-owner -xf R-3.1.1.tar.gz
cd C:\Work\R\R-3.1.1\src\gnuwin32\
make all recommended
Add the following path to the Environment variables
C:\Work\R\R-3.1.1\bin\i386
Enter the R.exe in command promt
I got the following Error
Fatal error unable to open the base package
System information
Windows 8, 64 bit operating System, x64 –based processor
How to resolve this error?
If you are using R, you can download the newest version from here and then simply install it.
If you have an older version and want only to download the new one, use those commands inside R:
# installing/loading the package:
if(!require(installr)) {
install.packages("installr"); require(installr)} #load / install+load installr
# using the package:
updateR() # this will start the updating process of your R installation. It will check for newer versions, and if one is available, will guide you through the decisions you'd need to make.
We can resolve this issue by using the following command before build the R source code
Set TMPDIR=c:\cygwin64\bin
Here c:\cygwin64\bin is the cygwin installed location in Windows 8 machine.
Here I have mentioned the R source code build steps:
Install cygwin setup
Install RTools
Create the R_HOME file in the directory like C:\R_HOME
Place the R source code tar file in the R_HOME
Add the following path in environment variable in first
c:\Rtools\bin\;c:\Rtools\gcc-4.6.3\bin;C:\cygwin64\bin\;C:\Program Files (x86)\HTML Help Workshop\;C:\R_HOME\R-3.1.1\bin\;
Enter the following command in the command prompt
Set TMPDIR=C:\cygwin64\bin
Set working directory as C:\R_HOME
Enter the following command
tar --no-same-owner -xf R-3.1.1.tar.gz
Copy the Tcl source from c:\R (it will be created while installing RTools)
Set the working directory as follow in command prompt
C:\R_HOME\R-3.1.1\src\gnuwin32
Enter the following command
Make all recommended
Enter the R.exe command in command prompt. We can enter the R terminal

Run Scheme Program in Sublime Text Ubuntu

I tried to run a program using scheme syntax but I couldn't. I got this ...
[Errno 2] No such file or directory: 'gsi'
[cmd: ['gsi', '-:d-', '/home/salinas/Documents/LP/scheme.scm']]
[dir: /home/salinas/Documents/LP]
[path: /usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" :/home/salinas/.rvm/bin]
[Finished]
Anyone knows how to solve this ?
If you want to use the configured Scheme environment (Gambit) you need to install it. Open a terminal (CTRL+ALT+T) and enter the following:
sudo apt-get intall gambc
Then gsi should be available.
If it doesn't work because the package was not found you may need to enable universe repositories and try again.

Resources