pip only collects package (matplotlib) not installs it - python

I am trying to setup object detection tensorflow api on my system by following this tutorial. All the steps work but matplotlib installation is not working. Pip is only collecting the matplotlib and not installing it. However if I install other package like Pandas, it installs properly.

I found a solution on Windows 7 64 Bit (Python 3.7) that worked for me:
Open cmd (console) in Windows. If you are on Windows 10 use powershell and enter cmd in powershell.
Navigate into the "Scripts" folder of your virtual environment using cd. In your example this should be "c:\tensorflow1\models\research\Scripts"
Verify that you are calling the python.exe in this folder (and therefore of this virtual environment) by typing python and hitting enter. Try to import matplotlib. This should not work since the package is not installed yet.
Do not activate the environment.
Use python -m pip install matplotlib to install the package.

Related

How to install TA-Lib On vscode/windows(64bit)

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.

How do modules installation work in Python?

[On a mac]
I know I can get packages doing pip install etc.
But I'm not entirely sure how all this works.
Does it matter which folder my terminal is in when I write this command?
What happens if I write it in a specific folder?
Does it matter if I do pip/pip3?
I'm doing a project, which had a requirements file.
So I went to the folder the requirements txt was in and did pip install requirements, but there was a specific tensorflow version, which only works for python 3.7. So I did """python3.7 -m pip install requirements""" and it worked (i'm not sure why). Then I got jupyter with brew and ran a notebook which used one of the modules in the requirements file, but it says there is no such module.
I suspect packages are linked to specific versions of python and I need to be running that version of python with my notebook, but I'm really not sure how. Is there some better way to be setting up my environment than just blindley pip installing stuff in random folders?
I'm sorry if this is not a well formed question, I will fix it if you let me know how.
Yes, there is. Setup an virtual environment.
pip install virtualenv #installs the library
virtualenv mypython #creates the environment
source mypython/bin/activate #activates the environment
Now, install your requirements through pip.
Afterwards, when your work is finished.
Just type deactivate to come out of the virtual environment.
There may be a difference between pip and pip3, depending on what you have installed on your system. pip is likely the pip used for python2 while pip3 is used for python3.
The easiest way to tell is to simply execute python and see what version starts. python will run typically run the older version 2.x python and python3 is required to run python version 3.x. If you install into the python2 environment (using pip install or python -m pip install the libraries will be available to the python version that runs when you execute python. To install them into a python3 environment, use pip3 or python3 -m pip install.
Basically, pip is writing module components into a library path, where import <module> can find them. To do this for ALL users, use python3 or pip3 from the command line. To test it out, or use it on an individual basis, use a virtual environment as #Abhishek Verma said.

Python 3.8 on Windows 10/Linux (Manjaro 18.1.5): ModuleNotFoundError for TestPyPI package installed with pip

I followed along with the package distribution tutorial for uploading a package on test.pypi.org from a Linux machine, and proceeded to try to install the package on a separate Windows machine.
On the Windows machine, I installed Python 3.8 and ticked the Add Python 3.8 to PATH box. No previous Python installation was present, and it installed to C:\Users\me\AppData\Local\Programs\Python\Python38\.
In Environmental Variables, my PATH under "Users variables" is: C:\Users\me\AppData\Local\Programs\Python38\Scripts\;C:\Users\me\AppData\Local\Programs\Python38\;%USERPROFILE%\AppData\Local\Microsoft\WindowsApps.
My PATH under "System variables" is much longer, but it contains no Python directories.
I then downloaded and installed pip.
In Command Prompt, I first created a virtual environment with py -m venv tutorial and activated it with Scripts\activate. Activation was verified by the (tutorial) next to the prompt. Then, in the virtual env, with py -m pip install ... I installed my example package.
I can verify it's installed by seeing it in the output of py -m pip list:
Package Version
----------------------- -------
example-pkg-me 0.0.1
pip 19.2.3
setuptools 41.2.0
example-pkg-me does not appear outside the virtual env.
The tutorial finishes by having you attempt an import in the Python interpreter:
py
>>> import example_pkg
but I get ModuleNotFoundError: No module named `example_pkg`. Why? Is something wrong with either of my PATHs? Note that the tutorial specifically mentions omitting the username (and import example_pkg_me issues the same error regardless).
Curiously, when trying to install and import a "mainstream (?)" package, it succeeds with no errors. I.e.,
py -m pip install numpy
and
py
>>> import numpy
works.
Update:
Same results on a separate Linux machine with the same steps where the only differences are that Python and pip were already present.
As an aside, if your package is intended to be run (as a GUI app) rather than imported in the interpreter as in the tutorial, how would the person who installed it run it? Would they have to navigate to the directory where the package files were physically installed and run a main.py script there? Is there a better way (like freezing the package as an executable with the likes of cx_Freeze and distributing the EXE instead of relying on pip installations)? Or maybe just expect them to download a repository, run py setup.py install, and then a main.py script?

How to install additional python libraries such as "bs4" or "Tensorflow" for SublimeText "virtualenv" package?

I use SublimeText for programming in python - it's easy and to build a program I have to just press Ctrl+b. To use additional libraries such as "requests" or "tensorflow" I've installed "VirtualEnv" package for SublimeText https://packagecontrol.io/packages/Virtualenv. I tried to use source /... my path.../activate, but instead of activation there is different python versions
suleyman#Linuxoid:~/.virtualenvs/bin$ ls
python python3 python3.6
And i can't use pip install bs4 (for example) to install additional python's libraries. So, how to install python's libraries in SublimeText's "virtual environment" package? Thank you
SublimeText itself doesn't install Python packages. Instead, the virtualenv package substitutes a Python binary that you specify instead of the system installation whenever you hit Ctrl+B. Your virtual environments are stored in the ~/.virtualenvs directory (though you can keep them anywhere). From your snippet above, it appears you have three virtualenvs installed, called python, python3 and python3.6.
To install TensorFlow or Requests, you need to activate your virtualenv from the terminal:
source ~/.virtualenvs/python3.6/bin/activate
Then run your installation commands:
pip install tensorflow
You can verify the installation completed successfully by running pip freeze.
In sublime, check the virtualenv package settings to confirm that it's pointed at your ~/.virtualenvs directory. When you run the command to select a virtualenv (Ctrl+Shift+P), you will see a list of all the virtualenvs saved to that folder. If you select the python3.6 environment, you can now use Tensorflow.

How to configure pip to install packages for python 2.x and python 3.x separately

I am running Windows x64 bit.
I downloaded the Pyro4 package via pip install Pyro4. It downloaded the packages successfully and they are all present in my "C:\Python34\Scripts" folder as I've kept Python3.4 as default.
Now when I went to the that "C:\Python27\Scripts" folder, the Pyro4 package is not to be found. This is as expected, but I would like to work on both Python 2.7 and 3.4 as Pyro4 is compatible in both.
How do I change my pip command to download the package to Python 2.7's installation scripts directory?
First make a new environment variable:
Go to your system properties
Under Advanced tab click Environment Variables...
Under System variables section click New...
Variable name: (whatever you can remember for example p27s)
Variable value: your python 2.7 scripts folder ("C:\Python27\Scripts\")
From now on whenever you want to install a package for python 2.7 you can do it this way: %your_variable_name%pip install package_name
For example: C:>%p27s%pip install Pyro4
This way you can install any package for python 2.7 and use default pip for python 3.4
You will need to go to your environment variables in the control panel and change the path from C:\Python34\Scripts to C:\Python27\Scripts. After that change, when you type 'python' in the command prompt it will be using Python 2.7. Next, install pip like you initially did.
Not exactly what you're asking, but you could check out Anaconda which allows you switch python environments really easily.
https://www.continuum.io/downloads
Edit
Just to clarify
if you were to use this method, you can have named environments say python27 and python34
then you can just:
activate python27
pip install module
activate python34
pip install module
and it will install them to both environments.

Categories

Resources