I am a trader, I want to use the XTB API to access the account,T try to learn Python I found XTBApi I install it Windows (python3 -m venv env)
but when I enter the command (. \ venv \ Scripts \ activate) it doesn't work: The specified path could not be found.
What do I have to do?
Thanks
How can i convert linux script to windows script :
git clone git#github.com:federico123579/XTBApi.git
cd XTBApi/
python3 -m venv env
. env/bin/activate
pip install .
From what I know of venv, activate is found in bin, try
venv/bin/activate
You've mentioned in the comment XTBApi\env\Scripts\activate.bat being present.
Execute that file because that's written in Windows' scripting language (Batch) instead of Linux/UNIX's scripting language (Bash). Those aren't compatible, nor have the same syntax.
XTBApi\env\Scripts\activate -> Bash (for msys2 or similar things that have Bash interpreter)
XTBApi\env\Scripts\activate.bat -> Batch (for cmd.exe)
There should also be a .ps1 file for Powershell, if you are using it.
Related
I am not able to activate the venv available in my project directory.
When I do the following it still doesn't activate the venv and I am not able to use python or pip installed in my venv.
/my_project$ source venv/bin/activate
(venv) /my_project$
It does show that the venv is activated but when I check python and pip, version and location it shows that both are from the root dir usr/bin/python & usr/bin/pip.
Venv Installation Process
/my_project$ python3.10 -m venv venv
It's working well in my new directory and I am also able to activate the venv but my existing venv in the project folder that I created yesterday is not starting. I am new to Linux and don't know much about it but I believe it has something to do with the Linux reboot as after the reboot this started happening.
Any help would be appreciated. Thanks
OS: Ubuntu 20.04.4 LTS
system python: 3.8.10
python3.10: 3.10.5
perhaps try explicitly setting the python version when creating your venv:
i.e.
/my_project$ python -m venv venv python=python3.10
https://stackoverflow.com/a/61775880/14327910
and from (https://python.land/virtual-environments/virtualenv):
Blockquote
Python 3.4 and above
If you are running Python 3.4+, you can use the venv module baked into Python:
$ python -m venv [directory]
This command creates a venv in the specified directory and copies pip into it as well. If you’re unsure what to call the directory: venv is a commonly seen option; it doesn’t leave anyone guessing what it is.
A little further in this article, we’ll take a close look at the directory that was just created. But let’s first look at how to activate this virtual environment.
my anaconda (4.5.4) works fine as long as I just use it via a linux terminal (bash shell). However, running conda commands in a bash script does not work at all.
The script test.sh containes these lines:
#!/bin/bash
conda --version
conda activate env
Now, running bash test.sh results in the error
test.sh: line 2: conda: command not found
test.sh: line 3: conda: command not found
As recommended for anaconda version > 4.4 my .bashrc does not contain
export PATH="/opt/anaconda/bin:$PATH",
but
. /opt/anaconda/etc/profile.d/conda.sh
Thank you.
I solved the problem thanks to #darthbith 's comment.
Since conda is a bash function and bash functions can not be propagated to independent shells (e.g. opened by executing a bash script), one has to add the line
source /opt/anaconda/etc/profile.d/conda.sh
to the bash script before calling conda commands. Otherwise bash will not know about conda.
If #randomwalker's method doesn't work for you, which it won't any time your script is run in a more basic shell such as sh, then you have two options.
Add this to your script: eval $(conda shell.bash hook)
Call your script with: bash -i <scriptname> so that it runs in your interactive environment.
Let's say you try to access user name with "miky" # "server" address.First when you login to your user ; learn conda path with "which conda" then probably you will get a path such as "/home/miky/anaconda3/bin/conda"
then put your conda commands as follow (in my example i use conda to install a mysql plugin forexample.): shh miky#server -t "/home/miky/anaconda3/bin/conda install -y -c anaconda mysql-connector-python" thats all.
do sudo ln -s /home/<user>/miniconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh and try again. This should activate conda for all users permenantly
source
I am experiencing an odd python thing! I can only use python 2; all other pythons (python3.4, -3.5) are gone; They exist in usr/bin, but I can't use them. For example, usr/bin/python3.4 invokes pyhton2.7. Two days ago everything was normal; I was using python3.4 just fine. All I did in last two days was to install a flask environment and I also purged teamviewer from my ubuntu.
One quick way to solve it, if you have Python 3 installed is typing python3.
Also, check this link, it probably solves your problem https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3
Check links in /usr/bin
ls -al | grep python
All python interpreters must be linked with our executable files.
Call python 3 with version, for example:
python3.4
Do not change symbolik link from python to python3, this can crash system scripts.
Install and use virtualenvwrapper:
pip install virtualenvwrapper
Check virtualenvwrapper location:
whereis virtualenvwrapper.sh
Add into you BASH config calling virtualenvwrapper and use it for creating virtual environment with python 3:
mkvirtualenv myvenv --python=/usr/bin/python3.4
Activate virtualenv and install required packages (root privilegies NOT required!):
workon myvenv
pip install flask
Call IDE from terminal with activated virtual environment for correct PATH working.
Enjoy!
Here is how I fixed it:
sudo apt-get install --reinstall python3.4
Now, everything is back to normal.
I would like to install Anaconda on a remote server.
The server is running Ubuntu 12.04.
I only have access to this server via SSH.
How can I install Anaconda via the command line?
Something along the lines of:
wget https://repo.anaconda.com/archive/Anaconda3-2020.07-Linux-x86_64.sh
to get the installer for 64 bit linux followed by:
bash Anaconda3-2020.07-Linux-x86_64.sh
You can get the latest release from here
Please take a look at the Anaconda repo archive page and select an appropriate version that you'd like to install.
After that, just do:
# replace this `Anaconda3-version.num-Linux-x86_64.sh` with your choice
~$ wget -c https://repo.continuum.io/archive/Anaconda3-vers.num-Linux-x86_64.sh
~$ bash Anaconda3-version.num-Linux-x86_64.sh
Concrete Example:
As of this writing, Anaconda3-2020.07 is the latest version. So,
~$ wget -c https://repo.anaconda.com/archive/Anaconda3-2020.07-Linux-x86_64.sh
~$ bash Anaconda3-2020.07-Linux-x86_64.sh
P.S. Based on comments, this should also work in CentOS systems.
You can do as Prashant said or you can use bash scripts to automate the installation. Just simply copy and paste depending on the version of Python you want
If you are trying to it entirely in command line you use a bash script
python 2 anaconda install bash script:
# Go to home directory
cd ~
# You can change what anaconda version you want at
# https://repo.continuum.io/archive/
wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh
bash Anaconda2-4.2.0-Linux-x86_64.sh -b -p ~/anaconda
rm Anaconda2-4.2.0-Linux-x86_64.sh
echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.bashrc
# Refresh basically
source .bashrc
conda update conda
python 3 anaconda install bash script
# Go to home directory
cd ~
# You can change what anaconda version you want at
# https://repo.continuum.io/archive/
wget https://repo.continuum.io/archive/Anaconda3-4.2.0-Linux-x86_64.sh
bash Anaconda3-4.2.0-Linux-x86_64.sh -b -p ~/anaconda
rm Anaconda3-4.2.0-Linux-x86_64.sh
echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.bashrc
# Refresh basically
source .bashrc
conda update conda
Source: https://medium.com/#GalarnykMichael/install-python-on-ubuntu-anaconda-65623042cb5a
Download Anaconda for linux, place in your ubuntu system through WinScp, then
$ sudo bash Anaconda2-4.3.0-Linux-x86_64.sh
after this logout of your ssh session and then login, you will get base environment.
1 - Go to Anaconda Repository, find the installation for your OS and copy the address
2 - wget {paste}. Ex: https://repo.continuum.io/archive/Anaconda3-5.2.0-Linux-x86_64.sh
3 - Execute with: bash. Ex: bash Anaconda3-5.2.0-Linux-x86_64.sh
Run!
$ sudo bash Anaconda2-4.3.0-Linux-x86_64.sh
Video tutorial::
https://youtu.be/JP60kTsVJ8E
Just download the anaconda installer and execute it as it is a shell script. Follow the steps :
In the terminal type "wget https://repo.continuum.io/archive/Anaconda-2.3.0-Linux-x86_64.sh"
The file will be downloaded in current directory. Now execute the downloaded file by "bash ./Anaconda-2.3.0-Linux-x86_64.sh"
Restart the terminal. This is very important for python version provided by anaconda to be set to default for that user.
Note- Try using environment for using different version of python. Changing the default python version for root might result in non functioning of some functionalities like yum.
I'm a newbie to Python and I've spent hours on this. I can't seem to figure out why when I run a simple command to setup my Python environment: virtualenv --distribute env
This doesn't create a bin file in the env directory.
It only creates:
-- env
-- Include
-- Lib
-- Scripts
My impressions was that a bin directory would be created per a lot of the examples I've found on the web (e.g. I'm not able to run this command: env/bin/activate).
I'm using Windows 7 and Python 2.7.
On Windows, this is entirely correct. A bin directory is created on POSIX systems only. From the Windows Notes section of the documentation:
Some paths within the virtualenv are slightly different on Windows: scripts and executables on Windows go in ENV\Scripts\ instead of ENV/bin/ and libraries go in ENV\Lib\ rather than ENV/lib/.
For Windows, run \path\to\env\Scripts\activate to activate the virtualenv. From the documentation again:
On Windows you just do:
> \path\to\env\Scripts\activate
And type deactivate to undo the changes.
Based on your active shell (CMD.exe or Powershell.exe), Windows will use either activate.bat or activate.ps1 (as appropriate) to activate the virtual environment.
If you're using Git Bash for Windows, I found the following command works to activate the environment: $ source (path to environment)/Scripts/activate
I was using Git Bash on Windows 10, Python(v3.7), Pip (v19.0.3), virtualenv (v16.4.3)
Yes, correct. On Windows, it creates the directory hierarchy as follows:
venv (virtual environment name)
Include
Lib\site-packages
Scripts
Just like in this image:
.
For windows , you have to run python -m venv <your_env_name> and
source <your_env_name>/Scripts/acivate.
This works for me on windows.