Work computer python package installation fail - python

i try to install a package sklearn-crfsuite https://pypi.org/project/sklearn-crfsuite/#files on my working computer in windows, where I do not have admin rights. Besides the root enviorment I already created my own enviorment following called: Test.
Normally I use anacando navigator to install new packages, there everything works fine, but this package is not in anaconda navigator, so I am opening the anaconda prompt /conda prompt to install in manually. Here the problem starts.
I start by choosing the right enviorment in the command line:
activate Test
I installed pip and scikit already and have the python version 3.6.8. So I try to run the following command:
pip install sklearn-crfsuite
And I get the error: Could not find a version that satisfies the requirement sklearn-crfsuite
Error: no matching distrubation found for sklearn-crfsuite

I found a soluation on my own, for everyone who will have this problem at some time, search for the package on anaconda cloud:
https://anaconda.org/derickl/sklearn-crfsuite
the command is changing just a little bit then:
conda install -c derickl sklearn-crfsuite
where derickl denotes the cloud.

Related

What is the difference between installing a package in my Windows CMD and in VS Code terminal?

I am doing this project where i need to install a package called Twint.
I want to install this package and use it's commands in my VS Code.
What happends when i for example type this in my Windows CMD?
pip3 install --user --upgrade git+https://github.com/twintproject/twint.git#origin/master#egg=twint
Because i can't type this in my VS code terminal, where i usually install packages with pip.
It will return an error that says ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?''
Now if i run this in my Windows Command it seems that i can't directly import the package in VS code?
Can anyone help me out with this confusion, where does the files get stored and how do i create good habbits around installing packages?
Hope someone understands what im struggeling with here.
Best
It is often the case that computers have more than one version of python installed and that editors like VS code use a different version than pip uses on the command line. pip installs packages where the version of python it is linked to expects them to be, but VScode doesn't know to look there.
It sounds like you have git installed where pip installs things, so you can upgrade from the command line without issue, but there's no installation of git where VScode is looking, so there's nothing to upgrade.
You either need to find where pip installs things and add it to the $PATH VScode uses, or try running a variation of python -m pip install --user git (specifying a specific url, or other things, as needed) from within VScode, which will ensure the package gets installed in a place that VScode looks for packages.
Download and Install git in your windows from here:
https://git-scm.com/download/win
Then add its installation bin path to your windows's environment path. Then you will find the git command at the command prompt globally.
This may solve you problem.

How to pip install GDAL on Python 3.6 venv

gdal is correctly installed on my global system's python 3.5 packages.
But now I'm trying to pip install gdal on my python 3.6 virtual environment, but I receive multiple errors.
After activating the virtual environment, I've tried the following:
pip install pygdal or pip3 install pygdal
Error received: ERROR: Failed building wheel for pygdal
Tried following this guide, but the commands stated there are outdated
I've also tried this solution and this which failed
Installed older gdal versions but also didn't work.
Tried pip3 install GDAL==$(gdal-config --version) and I get the same error
I use
Ubuntu 16.04 and pip 21.0.1. Venv was created using virtualenv --python=/usr/bin/python3.6 my_venv
I've finally fixed the problem, and these are the steps I followed:
I uninstalled wheel from my venv
Then I pip installed gdal on the venv to check what error would appear
A wall of error text appeared, in which somewhere I noticed the 'x86_64-linux-gnu-gcc' failed with exit status 1
I typed sudo apt-get install python3.6-dev to install missing packages, as the solution suggests here
Then I ran pip install GDAL=<version that appears on ogrinfo --version> and it worked
EDIT: This answer pertains more to Windows than Ubuntu, but may have something useful.
Try downloading a wheel from here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
Note the "cp##" in the middle - that should match your Python version. If you are running Python 3.6 then you should see "cp36" in the file name (a "cp37" in the name means the wheel will fail). Also pay attention to the amd64 and win32 to be sure you have the correct version to match your Python virtual environment.
I'm on Windows instead of Ubuntu, but this was my process:
Open command prompt with cmd
Copy the path to activate.bat in the virtual environment from Windows Explorer (hold shift down, right-click on file, choose
"copy as path")
Paste path into control panel and hit enter. You should see an indicator that you are in virtual environment.
Copy the path to the wheel you downloaded to the clipboard using the same shift key trick.
Type 'pip install ' then paste the wheel path from your clipboard (or type it all out manually)
As an aside, I ended up with gdal installed within the osgeo module. I tried several things before I got here, but I'm pretty sure that happened with my installation from the wheel. In Python, I now use
from osgeo import gdal
I hope something here helps you. I've run into this a few times and it never seems like I quite remember how I got it done the next time I run into it. If I remembered it right this time, I can refer back here.
FWIW - I am using PyCharm and installing gdal through the Project Interpreter doesn't work. Also, it may take some jostling in PyCharm for the skeletons to update after you install through command prompt.

How can I point my Spyder IDE to the path where all packages are installed?

I had a massive crash today and lost a lot of work. I couldn't start Spyder after many attempts; even tried 'spyder --reset'. Nothing worked. I decided to download a new version of Anaconda and start over. Now, I'm trying to figure out why I can't run packages.
If I run this: import pyodbc
I get this: ModuleNotFoundError: No module named 'pyodbc'
So, I go to the command prompt to pip install pyodbc...and apparently it's already installed...
When I navigate to that path, I can see the package
...but Spyder is still telling me it's not installed. What's an easy fix for this?
i had similar crash problems on Windows 10, what I learned is that I had several non-conda versions of python on my PC, and I used 'pip install' in my environments so it messed up with conda packages and it stop working.
What I did is that I uninstalled anaconda and non-conda python, cleaned up registry from python mentions, installed fresh new miniconda, and 'conda install spyder' in the new env, conda have created new folder
C:\Users\~~~\.spyder-py3\
Inside of it I found "spyder.ini" file, where incorrect variable was set:
"spyder_pythonpath = "
I changed it from
['C:\Users\~~~\anaconda3\pkgs',
'C:\Users\~~~\anaconda3\envs']
to
['C:\Users\~~~\miniconda3\pkgs',
'C:\Users\~~~\miniconda3\envs']
Please Upvote it take so much time
First open Spyder and click Tools --> Open command prompt.
You should see the Command Window appear in the bottom right of your screen.
Here we install the Python package seaborn as an example.
# In the command line, type pip install seaborn
C:\Users\your_username\Documents\Python Scripts>pip install seaborn
This will install seaborn on your machine.
Note:
To upgrade the pip version on Windows, type python -m pip install --upgrade pip on the command line.
On Windows, all of your Python packages can be found in the directory of C:\Anaconda2\Lib\site-packages if you use the default path when you install Anaconda.
To upgrade the pip version on OS X, type pip install --upgrade pip on the command line.

Command pip install --upgrade pip setuptools failed with exit code 1: Session venv failed

Windows 10
I originally installed the Anaconda distribution.
I installed nox and invoke using pip from the Anaconda prompt.
I did all my work in the Anaconda prompt and everything worked.
I needed to do some more testing and also needed a Python developer environment that mirrored what other developers in my team use (they don't use Anaconda) so I uninstalled the Anaconda distribution using 'Add or Remove Programs'.
I installed Python from python.org.
I ran into errors when trying to repeat my past workflow. I managed to fix some of them by uninstalling the packages I had installed using Anaconda prompt (nox and invoke) and reinstalling using the new Python distribution but I still have one problem shown in step 7.
C:\Users\user\Documents\GitHub\projectname>inv
Running session venv
Re-using existing virtualenv at .\venv.
pip install --upgrade pip setuptools
Command pip install --upgrade pip setuptools failed with exit code 1:
Session venv failed.
For background, invoke calls the following nox script
def venv(session):
"""Setup the developer environment."""
# Install dependencies.
session.install("--upgrade", "pip", "setuptools")
session.install("-r", "requirements-dev.txt")
session.install("-e", ".")
The problem was solved by deleting the virtual environment directory and running the inv command again. Since the virtual environment directory had been created with Anaconda, I assume that some of the scripts in it were pointing to the Anaconda distribution's files and that is where the error was coming from.

Issue installing pip and pandas

I am trying to install Pandas with Pip and am running into some strange issues. Command prompt reported that pip is an unrecognized command. I thought that was strange, but decided to definitively remedy that by installing pip with the following commands:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
I received the report that an existing version of pip was found, uninstalled, and the new version was installed. I then proceeded to run
pip install pandas
And I was informed that 'pip' is not recognized as an internal or external command, operable program or batch file.
I then added to the path environment and the issue is still persisting. It's worth noting that I installed Python 3.6 by installing Anaconda. What am I missing here?
The pip command is not found because it's not in your path.
You should add the following to your PATH environment variable:
;%PYTHON_HOME%\;%PYTHON_HOME%\Scripts\
A simple Google search should help you find how to change environment variables for you version of Windows.
For example, see this page from the Java documentation.
Try the following
C:\Users\Username>cd C:\Python27\Scripts
C:\Python27\Scripts>pip freeze
If you're using a different Python version, replace Python27, with your version of Python.
On windows you can use !pip install pandas in your Python program without having to open the windows/anaconda prompt.
But as others said, pip is not in your active directory and you would have to open the anaconda prompt or go to the library where pip is installed

Categories