I have installed Anaconda and then cd to my project folder and then I installed TALIB using
pip install TA_Lib-0.4.19-cp38-cp38-win_amd64.whl
When I run pip freeze on anaconda , talib can be found and runs without problem.
However when I use it on vscode, it seems to be a problem , the interpreter I have tried is the virtual env and conda interpreter on vscode.
Both keeps showing no module named talib because the module shown here is TA-Lib
Please advise.
Update :
Thank you
Thanks to #Jill Cheng
Basically the answer is tricky.
a. In the anaconda environment make sure you check the python version
python3 --version
b. Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib and download the suitable package . Since I am using python 3.9.1 and I am using 64 bits window. So I downloaded this file TA_Lib‑0.4.19‑cp39‑cp39‑win_amd64.whl
c. Then I ran python3 -m pip install {filename on b}
python3 -m pip install TA_Lib‑0.4.19‑cp39‑cp39‑win_amd64.whl
d. Check if talib is installed. Run
python3
e. Run the following command
import talib
f. If there is no problem , then you can put in on py file. For an example my py file is example.py
#example.py
import numpy
import talib
close = numpy.random.random(100)
upper, middle, lower = talib.BBANDS(close, matype=MA_Type.T3)
print(middle)
g. You should be able to see middle printed out once you run python3 example.py.
Please use the command "python --version" in the anaconda terminal and the terminal in VSCode to check whether the Python you are currently using is consistent.
When we are in different Python environments in VSCode, the modules are stored in different locations. Therefore, we need to select the Python environment in which the module "talib" is installed in VSCode (please choose the same Python used in anaconda).
Reference: Using Python environments in VS Code.
Here the solution of TA-LIB for Anaconda, Visual Studio Code and PyCharm.
step 1:
Find the version of your pc in the settings (just check if its 64x or 32x).
Then open the terminal and check your python version by typing python --version
step 2:
Then go to this link [https://www.lfd.uci.edu/~gohlke/pythonlibs/]
and on the list search for 'ta-lib', search by Ctrl+f if windows and Command+f in mac will be easier.
step 3:
once you clicked on the 'ta-lib' a new window with a list will be open, find the version of your python and pc under the TA-Lib section and you'll get a file in the download folder of your pc.
well, copy that file in the directory of the project you are working on.
step 4:
Open the terminal (any terminal) make sure to be in the directory where you just pasted the file, then type pip install then enter.
Then type again pip install ta-lib
step 5:
You can now work with ta-lib by just importing it.
Related
I'm getting the error in the title when running a .py script. I have pandas installed (version 0.24.2) as you can see in the screenshot. The Python version is 3.7.3. When I run the command import pandas as pd in a Jupyter notebook it works. However, when I have the same command in a .py file ("MyFile.py") and try to run that file using Anaconda command prompt I get this error. Same happens when using the Windows command prompt. Can someone please advise on how to solve this?
The 2nd screenshot above shows that I can't find a folder for pandas in site-packages but anaconda seems to think it's installed.
have you tried python3.7 MyFile.py?
If not, I would try it. Then if it doesn't work I'd create a new environment with python 3.7, and then install pandas and run your code:
conda create -n test_env python=3.7
conda activate test_env
pip install pandas
python MyFile.py
Probably you have installed Python and afterwards Anaconda.
AnaConda has its own python exe and Libs that are automatically installed. They're probably located in (Windows path): C:\ProgramData\AnacondaX\
So, if you go to C:\ProgramData\AnacondaX\Lib\site-packages\ you will see a folder "pandas". It means that Pandas lib is installed for Anaconda exclusively.
On the other hand, you have installed Python in c:\Python27. I'd advise you firstly add to %PATH% environment variable to get access to Python from any folder you're in and after please check the libs you have installed in your Python (not Anaconda) with (pandas is not listed there):
c:>pip freeze
Next step is to install pandas for your Python installation. Just do it:
c:>pip install pandas
Anaconda uses its own python installation, which by default, and as per this documentation, should be under C:\Users\<your-username>\Anaconda3\.
By installing pandas via Anaconda, and then specifically running the script with a different python installation, you're running a script using a library within environment that does not have that library installed.
You can try installing pandas to this separate python installation (I saw your pip install didn't work, you could again specify this python installation and use pip as a module):
'C:\python27\python.exe' -m pip install pandas
Or run the script with the Anaconda python installation by specifying that python installation:
{path_to_anaconda_python} MyFile.py
Where path_to_anaconda_python is path to Anaconda python installation (by default, within C:\Users\<your-username>\Anaconda3\)
When i run python -m pip install {package} inside the virtual environment i created with python -m venv env the package is installed inside the env/Lib folder, however when i want to use the package the venv interpreter can't find the package. For example I installed ipykernel, but when I try to run a cell inside Visual Studio code I get a message saying I have to install ipykernel and even if I accept this message and install it again I keep getting the message that I have to install ipykernel.
I already tried deleting all my versions of python and reinstalling python I also tried to set the global target of python to my library folder python pip config set global.target {path to venv Library}
I am using python 3.8.0 which is the only python installed on my pc. I also have windows 10 and my editor is visual studio code. Please help.
If I run python -m pip freeze requirements inside my enviroment nothing happens. When I run python -m pip freeze requirements outside my environment I get a list of all installed packages
Please enter the command "pip show ipykernel" in the terminal of VS Code to check whether this module is included in this environment. (It checks whether the installation location of the module is consistent with the Python environment displayed in the lower left corner of VSCode.)
If the terminal shows that there is no such module, please open a new VS Code terminal(shortcut key: Ctrl+Shift+`), it will automatically enter the environment displayed in the lower left corner of VSCode.
I'm trying to install new python modules on my computer and I know how to install through the terminal, but I wish to know if there is a way to install a new module directly through VSCode (like it is possible on PyCharm)?
I already installed through the terminal, it isn't a problem, but I want to install without be obligate to open the terminal when I'm working on VSCode.
You should open the terminal inside the VSCode and install the modules you want.
something like👇
if that's not you meant, please let me know.
First of all I would advise you to select the current Python version you have. It has been explained here:
VSCode: There is no Pip installer available in the selected environment
Next, you should check is the pip installed in your Python main directory or not, by checking how to do on this website:
https://pip.pypa.io/en/stable/installing/
or this thread
How to use pip with Visual Studio Code
by typing
py -m pip
in your terminal, like
C:\Users\m\Desktop\Python> py -m pip
You should have the list of commands and general options which can be used. One of them is install
On the Python library platform, you always have the command to be copied in order to the installation of package you want.
In your terminal, the initial command should look as:
PS C:\Users\m\Desktop\Python> py -m
to which you should append the command prepared on the Python library platform (by copying it and pasting).
C:\Users\m\Desktop\Python> py -m pip install openpyxl
That's it. The package should be installed in your Python folder, what you will see in the terminal.
If everything is alright, you just need to type
import openpyxl #or other package name, which you downloaded
and use it!
Unfortunately! for now, only possible way is terminal.
I'm trying to run the autopep8 linter on a Python file in VSCode.
I've followed the instructions here: https://code.visualstudio.com/docs/python/environments and selected my interpreter (⇧⌘P): /usr/local/bin/python
I then try to format my code, and VSCode says autopep8 isn't installed, and can be installed via Pip. However, when I try to install via Pip, it says There is no Pip installer available in the selected environment.
I then tried launching a terminal in the current environment by selecting Python: Create Terminal from the Command Palette.
The terminal opens fine, pip is present, and I'm even able to pip install autopep8 in the terminal that opened in VSCode, but when I try running the Format Document command I get the same errors that autopep8 and pip aren't available in the environment.
On Ubuntu16.04, I worked with Python3 in vscode and
apt-get install python3-pip
solves my problem.
That's because I discover that: Under my terminal, I type the pip -V. It displays it's for Python2, not for Python3.
Man you can only change the interpreter.
Go in (ctrl + shift + p), then type Python: Select Interpreter, this way you choose the version that your extension needs.
This worked for me.
I have multiple python versions:
2.7
3.6
3.7
Tell the vscode/ visual studio code, which version to use:
press the following (Show All Commands): Ctrl + Shift + P
paste the following: Python: Select Interpreter
Select one of the version that it shows, I have selected python 3.7.3 64-bit
Update python path in settings:
press Ctrl + , to open Settings
search for python.pythonPath
change python to /usr/bin/python3.7
Note: this may not be needed, however, make sure /usr/bin/python3.7 really exists for you, you may have at a different path like /usr/local/bin/python3.7, etc.
I had pip but it was 2.7, but since I am choosing python 3, it's pip needs to be installed
Run the following command in Terminal: apt-get install python3-pip
Restart vscode
With the above steps, all issues got resolved. Hope that helps.
try Ctrl+Shift+P
then type
Python: Select Interpreter
and select the python version.
Installing python3-pip fixed the issue for me.
apt-get install python3-pip
1.Select the File > Preferences > Settings command (⌘,) to open your User Settings.
2.Search and Create or modify an entry for python.pythonPath with the full path to the Python executable according to your requirements.For Example i changed it to python2.6 path to this path /usr/local/bin/python3.
I had the same problem today, none of the solutions helped me. Eventually, I figured it out myself.
I'm posting this answer for people who are having this problem. Just go to your ./venv folder and you will find a .cfg file.
Just make sure include-system-site-packages is set to true
home = /usr/bin
include-system-site-packages = true
version = 3.8.5
If it still doesn't work, just run sudo install python3-pip once in the terminal. Of course you could always change the version here as well.
(on mac)if you are using python3 but vscode told you pip was not installed , you could change python version on vscode bottom.
And I guess you are using another terminal but not bash , vscode's default terminal is bash. Bash don't know you have install pip#2.
For WSL users:
If you have your work files in linux subsystem path, you still need pip for windows in order to VSCode to use it.
On Ubuntu:
Make sure, that you have Python and pip installed.
Go to Settings, type python.py in search input. This should find Python Path settings.
Remove this path (if it is currently setted), save. Exit Code and set this to current value.
For me is /usr/bin/python3
Had this issue when trying use autopep8. For me - it had nothing to do with pip (I know it is installed) but the path the VScode python extension was using.
If you open up the extension and go to it's setting and scroll down, there is a path you can designate for autopep8: Python › Formatting: Autopep8 Path
I used the path recommended by these docs:
https://code.visualstudio.com/docs/python/editing#_formatting
Which was: python.formatting.autopep8Args
I stopped getting the error.
For Windows system check the environment variable>System variables
check the Path variable for the python path.(if not found set the path variable for python)
Copy the path and paste under vscode>file>preferences>settings>python.pythonPath
It worked for me.
I ran into this problem while learning django and the terminal would not let me pip install anything.
Create a virtual environment in shell and then use the path of the environment as your interpreter. This worked for me.
Note: You might want to create to create the environment in a different shell altogether and then upload the folder of the environment into vscode.
Then you open up the settings file in the environment folder.
This image will hopefully give you a good idea. Click Here
I was having a similar problem with pylint in a docker container. I realized that the reason the VS-Code-prompted pylint install didn't work for me was because I was using the global python installation (global inside my docker container, anyway), which can require elevated permissions to install things and VS code wasn't running as root in the container. According to the vs code python extension docs:
Note: If you're using a global environment and VS Code is not running elevated, linter installation may fail. In that case, either run VS Code elevated, or manually run the Python package manager to install the linter at an elevated command prompt for the same environment: for example sudo pip3 install pylint (macOS/Linux) or pip install pylint (Windows, at an elevated prompt)
Go in (ctrl + shift + p), then type Python: Select Interpreter,
then type Python: Select Interpreter and then click on "Enter interpreter path"
Then click on "Find.. Browse your file. "
Then type Python in c drive search bar and click on latest version of python in case if you have multiple version of python. Enter and modify wait for sometimes to complete then close.
After that restart your vs code.
It worked for me it will work for you also.
Note: This is a solution for Windows.
First make Sure your Python is installed properly. Run the following command:
py --version
If the Previous command is running fine it will give you your python version. In that case go ahead and check if pip is present or not. Run the below command to check:
py -m pip
If pip is present in your system it show give you a list of option and info. If that's the case then go Ahead and run pip. All you need to do is precede the command you would normally write with py -m. For example:
pip install flask
py -m pip install flask
This should solve your problem.
When following the Installing TensorFlow for Windows guide https://www.tensorflow.org/install/install_windows, after executing
C:\> pip3 install --upgrade tensorflow
I get the following error:
'pip3' is not recognized as an internal or external command,
It looks like pip3 isn't recognized at all (although PATH to python is set)
Run the following
python -m pip install --upgrade tensorflow
Assuming python is working, TensorFlow should get installed (at least the "Validate the installation" step is green).
This will work, if you are facing pip3 or pip is not recognized as an internal or external command issue on windows:
From the desktop, right click the Computer icon.
Choose Properties from the context menu.
Click the Advanced system settings link.
Click Environment Variables. In the section System Variables, find the PATH environment variable and select it. Click Edit.
A new pop up will open. Variable name will remain Path. We will change the Variable value to the location of the folder where your python scripts folder is located. Find it.
For e.g. I changed its value to C:\Users\rgupta6\AppData\Local\Programs\Python\Python35\Scripts
Close all remaining windows. Reopen Command prompt window, and run your pip3 install --upgrade tensorflow command or pip3 install tensorflow command
That is because you haven't setup the environment variable yet.
Follow the steps by #rajesh
I had the same problem and i found his answer helpful
Right click on This PC > Select Properties
Select Advanced system settings on the left
In the dialog box select Environment Variables
In the system variables section select path and cllck on edit
Select new and enter the path where the python scripts are..
it is mostly in C:\Users[your user name]\AppData\Local\Programs\Python\Python36\Scripts
Then ok.. to all the boxes opened
Close cmd if it is already open and now try installing tensorflow using pip again like this
pip3 install --upgrade tensorflow
Before running pip3 install --upgrade tensorflow
you need check if you are using the correct Python 3.5 installation:
Python 3.5.2 [MSC v.1900 64 bit (AMD64)] on win32
Notice the 64 bit part.
Otherwise, it gives the above error.
You are going to install tensorflow-1.0.1-cp35-cp35m-win_amd64.whl, therefore double check your correct version (mostly this is happening you have both Python 2.7 and 3.5).
when installing python, on the install window, check the box "Active path"(something like that), which builds up a path link. So you can run "pip3 install" at anywhere.
Typing the python command before that should do the trick. In my case (on Windows 8.1 with Python 3.6), I had to type 'py' instead of 'python' as follows:
py -m pip install --upgrade tensorflow
The answer depends on the system you're using.
The issue is your path in the cmd is not that of where your python scripts are placed. In this case you can either navigate to "AppData\Local\Programs\Python\Python36\Scripts" in your terminal and then run the command or you can simply put C:\Users\Your User Name\AppData\Local\Programs\Python\Python36\Scripts to Path variable.
Then re-launch your cmd and type "pip3 install tensorflow" and see the feel the happiness :)
I just experienced the same issue, most likely you downloaded a zipped version of python, then unzipped it, and added it to $PATH just like me, python can work but pip3 cannot, and python -m pip cannot either.
fix solution is to download a executable version of python, then follow common installation steps, pip3 is selected by default, then everything is OK now.