Google Colab No Such File or Directory Error - python

Hello I'm trying to start tensorflow training process on google colab. I'm trying to run this code block in integrated notebook on google colab. Code block is:
!apt-get install protobuf-compiler python-pil python-lxml python-tk
!pip install Cython
%cd '/content/gdrive/My Drive/models/research/'
!protoc object_detection/protos/*.proto --python_out=.
import os
os.environ['PYTHONPATH'] += ':/content/gdrive/My Drive/models/research/:/content/gdrive/My Drive/models/research/slim'
!python setup.py build
!python setup.py install
It gives this output:
Reading package lists... Done
Building dependency tree
Reading state information... Done
protobuf-compiler is already the newest version (3.0.0-9.1ubuntu1).
python-lxml is already the newest version (4.2.1-1ubuntu0.4).
python-pil is already the newest version (5.1.0-1ubuntu0.6).
python-tk is already the newest version (2.7.17-1~18.04).
0 upgraded, 0 newly installed, 0 to remove and 39 not upgraded.
Requirement already satisfied: Cython in /usr/local/lib/python3.7/dist-packages (0.29.23)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
/content/gdrive/My Drive/models/research
python3: can't open file 'setup.py': [Errno 2] No such file or directory
python3: can't open file 'setup.py': [Errno 2] No such file or directory
I think I cant set python path correctly. Can anyone help me please?

You have to first mount your Google drive:
from google.colab import drive
drive.mount('/content/gdrive')
Try to do
import os
os.listdir(os.getcwd())
This should return
['.config', 'sample_data']
before you mount the drive, and
['.config', 'gdrive', 'sample_data']
after you've mounted the drive.

Related

Cannot import library covsirphy

I am trying to import library COVSIRPHY to jupyter notebook following two steps:
pip install --upgrade covsirphy (I installed it using terminal in specific environment created in anaconda navigator)
It was installed successfully
import covsirphy as cs
I typed in directly in jupyter notebook, but it occured an error:
OSError: dlopen(/opt/anaconda3/envs/test/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so, 0x0006): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib
Referenced from: /opt/anaconda3/envs/test/lib/python3.9/site-packages/lightgbm/lib_lightgbm.so
Reason: tried: '/usr/local/opt/libomp/lib/libomp.dylib' (no such file), '/usr/local/lib/libomp.dylib' (no such file), '/usr/lib/libomp.dylib' (no such file)
It is trying to search a path which does not exists, but physically the file libomp.dylib is located in other path, but I have no idea why it is seeking in this path.
I am wondering whether this library is possible to install on Mac with chip M1.
enter image description here
enter image description here
Please re-install libomp to save 'libomp.dylib' file at '/usr/lib/libomp.dylib' or update PATH to include the current path.
An alternative:
Because the latest development version of covsirphy does not depend on lightgbm, try to reinstall the latest version (>= 3.0.0.dev7).
pip install --upgrade "git+https://github.com/lisphilar/covid19-sir.git#egg=covsirphy"

Python sklearn installation windows

When trying to install Python's sklearn package on Windows 10 using pip I am given an EnvironmentError that tells me there is no such file or directory of a specific file:
ERROR: Could not install packages due to an EnvironmentError: [Errno
2] No such file or directory:
'C:\Users\Rik\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\sklearn\datasets\tests\data\openml\292\api-v1-json-data-list-data_name-australian-limit-2-data_version-1-status-deactivated.json.gz'
I have tried reinstalling the following packages numerous times:
scikit-learn
scipy
sklearn
I have also tried downloading the github master folder for sklearn and pasting it into the directory where the installer expects the file to be, and even then when installing with pip it tells me the file is missing.
Furthermore I tried installing it via the github repository by downloading it and running
python setup.py install
But this results in weird Microsoft Visual Studio errors because apparently it is trying to run a test program or something, not sure.
Any suggestions to fix this problem?
You can find the solution here: https://scikit-learn.org/stable/install.html
The problem occurs because the default path size limit is reached in your case, you can change this with the following steps:
open regedit tool (using windows cmd)
access the 'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem' key
change the 'LongPathsEnabled' value to 1
reinstall sklearn using the command 'pip install --exists-action=i scikit-learn'

pip install setup.py missing when attemping install of pyodbc wheel file

i'm trying to update the pyodbc package from 4.0.16 to 4.0.22.
i dont have internet access on the machine i'm working on so downloaded the file and copied to across the network.
running
pip install S:\Temp\PMCD\pyodbc-4.0.22-py27hc56fc5f_0(1).tar.bz2
results in the following error:
Processing s:\temp\pmcd\pyodbc-4.0.22-py27hc56fc5f_0(1).tar.bz2
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
IOError: [Errno 2] No such file or directory: 'c:\\users\\adm_pa~2\\appdata\\local\\temp\\2\\pip-yf25bd-build\\setup.py'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\adm_pa~2\appdata\local\temp\2\pip-yf25bd-build\
setuptools has already been updated to latest(38.5.1) and pip as well (9.0.1)
i used pip to update setuptools and pip itself (via downloaded whl files), so i dont think pip is an issue.
i already managed to sucessfully upgrade pyodbc on my local machine from 16 to 22, so the whl file i have not sure whats going on.
Any ideas whats going on?
Could i manually unzip the package and place it directly in the site-packages? that didnt seem to do anything.
If your target machine does not have a direct Internet connection you can still install pyodbc by
using another machine to download the appropriate wheel (.whl) file from PyPI,
copying that file to your target machine (via LAN, SneakerNet, ...), and
using pip install <wheel_file_location>
For example,
pip install C:\__tmp\pyodbc-4.0.22-cp27-cp27m-win_amd64.whl
The naming convention for wheel files is described in PEP 491.
The 64-bit wheel files for Windows are tagged as "win_amd64" because that's what the Windows version of distutils reports as the platform:
>>> from distutils import util
>>> distutils.util.get_platform()
'win-amd64'

NLTK | Sentiment Classifier | Issues with Install

I am having trouble installing the sentiment_classifier.
What I have currently done:
pip install sentiment_classifier
python setup.py install
Downloaded sentiment_classifier-0.5.tar.gz
Placed the package into my directory
Error in shell:
pip install sentiment_classifier:
Requirement already satisfied: sentiment_classifier in c:\users\ac\anaconda3\lib\site-packages
Requirement already satisfied: numpy in c:\users\ac\anaconda3\lib\site-packages (from sentiment_classifier)
Requirement already satisfied: nltk in c:\users\ac\anaconda3\lib\site-packages (from sentiment_classifier)
Requirement already satisfied: argparse in c:\users\ac\anaconda3\lib\site-packages (from sentiment_classifie
)
python setup.py install - C:\Users\AC\Anaconda3\python.exe: can't open file 'setup.py': [Errno 2] No such file or directory
When I call it in Jupyter Notebook:
from senti_classifier import senti_classifier
I get:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\AC\Anaconda3\lib\site-packages\senti_classifier\data\SentiWn.p'
Any help would be greatly appreciated.
Docs I've been referring to:
https://pypi.python.org/pypi/sentiment_classifier
Sentiment Analysis using senti_classifier and NLTK
https://github.com/kevincobain2000/sentiment_classifier
http://pythonhosted.org/sentiment_classifier/
Any help would be greatly appreciated.
It is missing some files needed for it to work and no those files aren't downloaded when you install the package using pip, you can download the repository for the library from https://github.com/kevincobain2000/sentiment_classifier and then copy paste the files inside the '/src/senti_classifier/data/' into your library's directory which is 'C:\Users\AC\Anaconda3\lib\site-packages\senti_classifier\data' directory.

Anaconda pip offline installation including dependencies (tensorflow)

I want to install tensorflow in an anaconda environment on a system without internet connection, and where I have not got root access (i.e. I want to install it to my local user only)
I have downloaded the .whl files of tensorflow and the required dependencies and copied them to the machine I want to use. Once I've entered my anaconda environment I started installing the packages using
pip install -b working_directory/build -t working_directory/target package.whl
But when I want to install a package which depends on an earlier installed package, it cannot find it.
So I wonder, how can you tell pip where to look for dependencies? Can I install tensorflow in an easier way, still offline and without root?
I am using PyCharm for the development with anaconda. I was also facing issue while installing tensorflow using conda, I also installed the python 3.6 and used the steps given on the tensorflow website. But finally I solved this using below steps and made it work on pyCharm:
Step 1: I downloaded binaries (.whl) file of tensorflow (The links of binaries are given on the git page https://github.com/tensorflow/tensorflow)
Step 2: Then I installed the tensorflow offline using below command:
pip.exe install --upgrade --no-deps C:\Important_Software\tensorflow-1.3.0rc0-cp36-cp36m-win_amd64.whl
Step 3: Then Tensorflow files have been created at below location:
C:\Program Files\Python36\Lib\site-packages
I copied these files and pasted in the Anaconda site-packages (Anaconda3\Lib\site-packages).
Step 4: Tensorflow is installed but below error has come when running the basic program:
File "C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ModuleNotFoundError: No module named 'google'
Step 5: I have solved this error using pip installation of protocol buffer
pip.exe install --upgrade --no-deps "C:\TarFile_location\protobuf-3.3.0.tar.gz"
Step 6: After this 3 files “protobuf-3.3.0-py3.6-nspkg.pth”, “protobuf-3.3.0-py3.6.egg-info” and “google” are created at the below location:
C:\Program Files\Python36\Lib\site-packages
These three file should be pasted at the Anaconda site-packages. (Anaconda3\Lib\site-packages)
Step 6: The I ran the below program and It worked:
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
If there will be still some Errors then all dependencies have to be downloaded and installed similar as step 2 or 5 from https://pypi.python.org/pypi/tensorflow.
Important note: I was using the Windows command prompt with admin Access.

Categories