How to make a shell script setup file see my conda environment - deep-learning

I'm trying to apply the CyCADA paper: https://github.com/jhoffman/cycada_release/tree/8629c03fe78a72d4aaa0be1a434018f8600dfae4
I'm trying to run the "train_cycada.sh", but I get an error "No module named 'torch'", even though i have torch on my conda environment. I guess the problem is that bash on windows doesn't see the conda environment .... anyone know how to fix that?

Related

VSCode with Remote Docker does not launch Anaconda base and does not recognize the conda command

I use WSL2 and Desktop Container and my system is Windows 11. I create a container(the system used in the container is Ubuntu 20.04) and then connect the container with VSCode (remote docker). I have installed a miniconda in the container. But when I connected the container with VSCode, I can't use any conda commands. It seems that VSCode blocks the miniconda or doesn't recognize it. But I can use conda commands in this container if I access the container with "docker exec"(not with VSCode).
When I run "conda -h" in the VSCode, it shows the following information(conda does not work):
$ conda -h
bash: conda: command not found.
When I run "conda -h" in a container terminal(access with "docker exec"), it shows(conda works):
(base) root ➜ / $ conda -h
usage: conda [-h] [-V] command ...
conda is a tool for managing and deploying applications, environments and packages.
This problem may be similar to the problem which might cause by the VSCode while connecting a running container(VSCode does not launch Anaconda base Python).
But I have no idea why they happened.
Does anybody have any improvement to these problems? Thank you.
Python works all well in both cases.
The miniconda was installed into the Ubnutu system after I created the container. Is it the reason that VSCode does not recognize the conda commands?
I had problems with the same combination (vs code and anaconda) on Window 10.
In fact, there is a chance that you have to define your PATH variables for Anaconda and that it will work fine after that...
1. path\to\Anaconda\Scripts
2. path\to\Anaconda\Lib
3. path\to\Anaconda\
but it isn't the most elegant way. According to Anaconda the preferred way is working with a $PROFILE and $ENV VARIABLES
But on stackflow, are a lot of posts about similar problems I noticed:
Maybe in some of the comments you find your answer?
Conda: Creating a virtual environment
https://stackoverflow.com/questions/53137700/ssl-module-in-python-is-not-available-windows-7]
I hope you'll find it fast, probably something small and easy to change.
Like choosing the right terminal from VS Code or so...
Good luck!

Pytorch already installed using Conda but fails when called

I am trying to install pytorch for using BERT but when following the installation instructions found here: https://pytorch.org/get-started/locally/ I am getting an error.
When I try and initalise the BERT model I get the following error:
ImportError:
BertForSequenceClassification requires the PyTorch library but it was not found in your environment.
Checkout the instructions on theinstallation page: https://pytorch.org/get-started/locally/
and follow the ones that match your environment.
I have followed the instructions and run the following command line in my Conda prompt terminal AND in my current working directory:
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
It looks to complete but when I try and call the following line I get the same error as the start as if it hasn't installed at all.
Can anyone help me out please.
EDIT:
The code I am using to execute bert is:
model = BertForSequenceClassification.from_pretrained(r'C:\Users\441\bert\pytorch_model.bin', config = r'C:\Users\441\bert\config.json')
I had the same issue (same error msg), and after using conda list | grep torch I also found it is there. What worked for me is that I restarted the jupyter notebook kernel and the error is gone.

How to install Google Apis Drive v3 via command line on Ubuntu-18.04

I have been trying to install Install-Package Google.Apis.Drive.v3 using this source with the difference that I have Ubuntu-18.04 instead of Windows.
I know it may be a simple question but I have been trying research how to do that from this morning. I installed sudo apt install nuget on my machine and have been trying to add packages or as in this case the Google.Apis.Drive.v3 package but no luck.
I went through this source which was useful, but does not carry information I was able to replicate on my Linux machine.
Also this source, this one and this one too. But also this last one is for Windows and was not very useful.
How do I install Google Apis Drive V3 via command line easily as it is documented for windows but on Ubunbtu-18.04?
Thanks for pointing to the right direction for solving this problem.
Solution
The way you install your Drive API's library is depending on the programming language you are aiming to use. These are the following commands to run depending on the different languages to interact with the API (with their respective links to the source of the setup):
Python:
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
C#/.NET:
Create a new Visual C# Console Application project in Visual Studio.
Open the NuGet Package Manager Console, select the package source nuget.org, and run the following command:
">Install-Package Google.Apis.Drive.v3
Java:
gradle init --type basic
mkdir -p src/main/java src/main/resources
Node.js:
npm install googleapis#39 --save
For the Browser check out the steps to follow here
I hope this has helped you. Let me know if you need anything else or if you did not understood something.
NOTE: For all Ubuntu-18.04 users that wish to install via command line the correct way is: sudo dotnet add package Google.Apis.Drive.v3

ModuleNotFoundError when running functional python tests despite that textX command works

I followed the set of instructions for this open source.
At step 3, I am supposed to run
py.test tests/functional/
When I do so, I get
ModuleNotFoundError: No module named 'textx'
However, when I type textx, it's definitely working as a command.
Where did I go wrong?
The PYTHONPATH is not set by py.test, see https://docs.pytest.org/en/latest/pythonpath.html#pythonpath
As described in https://github.com/igordejanovic/textX/blob/master/CONTRIBUTING.md you install textX in your virtual environment. If you omit 'pip install -e .' you get the described behavior.
As mentioned above, you can set the PYTHONPATH manually. Alternatively you can also run 'python -m pytest tests/functional' as proposed on the py.test website.
It is unclear to me why the textx command works in your example. Maybe you installed textX outside your virtual environment after creating the virtual environment?
Run export PYTHONPATH=. before running the py.test tests/functional/ and it should work.
This error may have occurred because I installed textX outside my virtual environment after creating the virtual environment.

'ALGOLIA_API_KEY' not recognized as an internal or external command

I am trying to run algolia for the first time but it seems that there is something wrong with my environment. I followed the detailed explanation here https://community.algolia.com/jekyll-algolia/getting-started.html.
I installed and configured everything that is needed from the previous steps but when I run the command
ALGOLIA_API_KEY=xxxxxxxxxxxxxx bundle exec jekyll algolia
I get an error:
'ALGOLIA_API_KEY' is not recognized as an internal or external command,
operable program or batch file.
I have been rereading the documentation for both jekyll and angolia but couldn't find anything that could be helpful.
Since you're running on Windows, you cannot set an environment variable for your command like you can do on UNIX.
As advised in this question, Setting and using variable within same command line in Windows cmd.exe, I believe you could use
set ALGOLIA_API_KEY=xxxxxxxxxxxxxx && bundle exec jekyll algolia