I found a great Medium article on creating a new neural network architecture that I wanted to try out. Of course, I get to the training part, and things start to fail.
I can't import TensorFlow. Whenever I do, I get the error
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import * # pylint: disable=redefined-builtin File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow File "/home/myusername/.virtualenvs/worldmodels/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 25, in <module>
from tensorflow.python.platform import self_check ImportError: No module named 'tensorflow.python.platform'
Well, I looked at this which suggested importing in a different folder which did not work. I also tried exporting the PYTHONPATH variable, set to PYTHONPATH="/home/London/.virtualenvs/worldmodels/lib/python3.5/site-packages" and PYTHONPATH="${PYTHONPATH}:/usr/local/lib/python2.7/dist-packages/" and PYTHONPATH="/usr/local/lib/python2.7/dist-packages/", all to no avail.
This one seemed to be a language issue, which shouldn't be my problem (and if it is, I don't know what they did to fix it.)
This one gave the same folder changing advice. This one seemed to be an issue with someone's command, not just trying to import it. And this one again suggests the setting PYTHONPATH. (And yes, I did see this one, but both the question and answer quality are lacking.)
Any ideas as to what I could do to get TensorFlow up and running?
(Maybe using a different install process than just pip? I have already tried installing by running sudo pip install tensorflow. I would still like to be able to use it with the Medium tutorial though.)
The issue was resolved by typing
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp35-cp35m-linux_x86_64.whl
#ProQ does a better job explaining how they were able to resolve it!
It looks like there was some other weird stuff going on. The biggest thing I noticed that was odd is that sudo pip --version gave a different version than just pip --version.
Doing pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.8.0-cp35-cp35m-linux_x86_64.whl upgraded and allowed me to import tensorflow. (Note that doing sudo pip did not work.)
Thank you #HarisNadeem for the solution and for helping diagnose the issue!
Related
I want to use the kitsu module in python. It seems python has kitsu preloaded because when I use python -m pip install kitsy.py it installs no problem. But when I try to run the basic test code they have on https://pypi.org/project/kitsu.py/ it tells me the following error.
Traceback (most recent call last):
File "c:\Users\ssolmonson\AppData\Local\Programs\Python\Github\Personal\kitsu.py", line 1, in <module>
import kitsu
File "c:\Users\ssolmonson\AppData\Local\Programs\Python\Github\Personal\kitsu.py", line 4, in <module>
client = kitsu.client()
AttributeError: partially initialized module 'kitsu' has no attribute 'client' (most likely due to a circular import)
I have looked all over on how to completely remove a preloaded module with little success.
I can see the kitsu module listed when using help('modules'). Some places said to run python -m pip uninstall kitsy.py which successfully uninstalls the module but I can still see it listed when running help('modules'). Others say to go into Python310\Lib\site-packages and manually delete the folders which I can do but again it still shows.
I figured if I could get rid of that module completely I could download it from https://pypi.org/project/kitsu.py/ and install it from the package I got from the website. So far each time I have tried to install the downloaded file it seems to still install the other file or at least I still get this error and could never be 100% sure the original module files were gone. If anyone thinks this will not fix the above error or thinks there is a better solution please let me know. I am truly grasping at straws.
I am trying to interact with a tool called Valor NPI using a Python script. This tool is used for designing and manufacturing electronic goods. As my first step, I ran a simple "hello world" program and it's running fine. But when I try to run some script using Python modules, it is showing a ModuleNotFound error. To resolve this problem, I've put the required modules and pip manually in that location (\Valor\vNPI_114\edir\all\python). Then, to check if it worked, I wrote a small script using the numpy module and tried to run it in that Valor tool. But it is showing the following error:
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/MentorGraphics/Valor/vNPI_DIR/sys/scripts/numpy1.py", line 2, in <module>
import numpy as np
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\__init__.py", line 150, in <module>
from . import core
File "C:\MentorGraphics\Valor\vNPI_114\edir\all\python\numpy\core\__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "C:\MentorGraphics\Valor\vNPI_114\edir\nv\deps\Python\python.exe"
* The NumPy version is: "1.21.4"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: No module named 'numpy.core._multiarray_umath'
How can I solve this? How can I use Python modules in that tool?
Python packages are installed in different ways, usually using pip, sometimes using a setup.py, but generally not by just coping a module to your Python directory. In most cases, that won't work.
I have no experience with the Valor NPI tool, and I recommend first searching for documentation of that tool if it supports third-party Python modules. Maybe there is a recommended way of installing.
Otherwise, I think you should install the needed modules using pip for this specific Python installation. In your case, I would execute:
C:\MentorGraphics\Valor\vNPI_114\edir\nv\deps\Python\python.exe -m pip install numpy
And likewise for other packages that you need (replacing numpy by the corresponding module). Since you already copied numpy to your Python directory, you should remove that to avoid conflicts between the different copies.
It looks like it could not find _multiarray_umath.cp310-win_amd64.pyd under your numpy/core folder.
Like #wovano, I suggest you install the module through pip instead of copying the module folder. Sometimes it can work, sometimes will not.
You can follow these steps:
In the terminal create a virtual environment through the command of
python -m venv .venv
use the Python: Select Interpreter command from the Command Palette
(Ctrl+Shift+P) to select the virtual environment .venv
Create a new terminal(Ctrl+Shift+`) that will activate the .venv virtual environment automatically
install the NumPy with the command of pip install numpy
You can refer to this official doc for the detailed steps.
I'm currently trying to run a Python program that uses RDKit and am facing an error. The get straight to the point, the complete traceback is:
Traceback (most recent call last):
File "./main.py", line 4, in <module>
from train import Trainer
File "/home/user1/repo1/train.py", line 12, in <module>
from utils import make_batches
File "/home/user1/repo1/utils.py", line 9, in <module>
from rdkit import Chem, DataStructs
File "/home/user1/anaconda3/envs/user1conda/lib/python3.7/site-packages/rdkit/Chem/__init__.py", line 18, in <module>
from rdkit import DataStructs
File "/home/user1/anaconda3/envs/user1conda/lib/python3.7/site-packages/rdkit/DataStructs/__init__.py", line 13, in <module>
from rdkit.DataStructs import cDataStructs
ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.11' not found (required by /home/user1/anaconda3/envs/user1/lib/python3.7/site-packages/rdkit/DataStructs/../../../../libRDKitDataStructs.so.1)
I've taken a look at this Git Issue and tried all the suggestions there, but none of them have worked. I also took a look at the following Stack Overflow questions as well: uwsgi: /usr/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /usr/lib/x86_64-linux-gnu/libicuuc.so.55 and /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version CXXABI_1.3.8' not found [closed] but the answers have not been able to solve my problem either.
For a bit more information:
OS: Ubuntu 16.04
Python version: 3.7.5
Output of echo $LD_LIBRARY_PATH is currently nothing (I've tried to set this to what the answers have suggested).
I'm currently using a Conda environment and also downloaded RDKit from Anaconda.
Would anyone know what the potential problem may be? I'm a bit perplexed as nothing seems to be working and I don't know where to start diagnosing the problem. Thanks in advance.
(This has been answered hundreds of times on StackOverflow)
This means the libRDKitDataStructs.so.1 library was built by a new version of GCC and your system compiler is an older version. The library depends on the version of libstdc++.so that comes with the new version, but it's finding the old one from your system compiler.
You need to ensure that the runtime linker knows how to find the new libstdc++.so, see https://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.how_to_set_paths an https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dynamic_or_shared.html#manual.intro.using.linkage.dynamic
For all those stuck with a similar problem, update your Anaconda/Miniconda with the following command:
conda deactivate
conda update conda
It works for me, hope it can help someone.
I'm rather new to using python and haven't done really anything to configure python. my professor gave us an autograder.py file that checks our python code for correctness. the autograder.py file imports a file called grader.py which then imports something known as cgi (import cgi). inside this cgi file located at '/usr/lib/python2.7/cgi.py' there is a line of code that says
from operator import attrgetter
this is where the problem occurs. i recieve the following error
Traceback (most recent call last):
File "autograder.py", line 12, in <module>
import grading
File "/home/ggkfox/Documents/164-CSCI/1-Assignment/tutorial/grading.py", line 13, in <module>
import cgi
File "/usr/lib/python2.7/cgi.py", line 37, in <module>
from operator import attrgetter
ImportError: No module named operator
it is my understanding that the operator module should be built in (according to other stack overflow posts). this error only occurs when i use python2.7.12 (as opposed to python3.5). i have had a simular issue importing Tkinter in 2.7 aswell.
also i want to say that i have tried uninstalling python using:
sudo apt-get purge python2.7
but it wont even uninstall for me to even attempt to reinstall. im not using any pipenv or desktopenv.
i dont know what else to say, im very new to python coding.
It is almost a necessity to use a virtualenv for each python project.
A virtualenv creates a dedicated python environment and it saves you from a lot of 'operating system' related issues.
Here, you can find some virtualenv solutions compatible with all Python versions, along with the official python 3.6.4 documentation.
I want to use the python wrapper from igraph. Compiling igraph and installing python-igraph works fine, but when I try to import igraph I get the following error (see image link below):
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/igraph/__init__.py", line 34, in <module>
from igraph._igraph import *
ImportError: /usr/local/lib/python3.4/dist-packages/igraph/_igraph.cpython-34m.so: undefined symbol: igraph_gomory_hu_tree
Error message screenshot
I also had some trouble with igraph and python, my solution:
delete your currently installed version of igraph and python-igraph
create a new virtualenv with pyvenv-3.4 yourVenv
activate the virtualenv . yourVenv/bin/activate
install python-igraph within the virtualenv pip install python-igraph
That one works for me.
Try using the 'wraptext' import that comes with python. Then use .fill() to wrap the text over the next line. That might work.
It's because python doesn't find the igraph library. You can simply export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ (or wherever the file libigraph.so is located on your system).
FYI: Tried for more than a day with all kinds of resources online for installing python-igraph on mac. And I also wasn't able to import graph in .py file or .ipynb. Though it did allow me to import igraph in terminal when launching python. My solution is to make a virtual environment, conda install -c conda-forge python-igraph, then switch python from version 3.8 (which never passes the igraph.test.run_tests, Failed = 2) to 3.5 (passed the test). Hope it helps.