I've used Pyinstaller to create an executable. The file is 80MB, 21 of which are from the numpy-atlas.dll file. However, my code does not use the numpy import.
It does have matplotlib.pyplot, but I was under the impression that only .pylab would contain numpy. Here are my imports.
I assume I am just being dense.
import os
import pickle
import tkinter as tk
import matplotlib.pyplot as plt
import pandas as pd
import periodictable as pt
import csv
from collections import OrderedDict
Related
I'm trying to use Open AI's anytrading environment, but I'm running into this issue during setup. Has anyone come across this before?
ModuleNotFoundError: No module named 'gym.wrappers.order_enforcing'
import gym
import gym_anytrading
from stable_baselines3.common.vec_env import VecFrameStack, DummyVecEnv
from stable_baselines3 import A2C
import numpy as np
import pandas as pd
from matplotlib import pyplot as plt
env = gym.make('stocks-v0')
I am trying to implement the code in https://github.com/kexinyi/ns-vqa.
However, when I try the command, python tools/preprocess_questions.py \ ... in the section of "Getting started". I see a message No module named 'utils.programs'.
Then I install utils and which makes import utils work, but import utils.programs does not work.
Does anyone have any idea to solve it?
import os
import argparse
import json
import h5py
import numpy as np
import utils.programs as program_utils # this one cannot be imported
import utils.preprocess as preprocess_utils
import utils.utils as utils
Solution:
Add the below lines at the beginning of preprocess_questions.py file.
import sys
sys.path.insert(0, "..")
This should solve your problem.
Explanation:
It is failing because preprocess_questions.py don't know about the path of utils.programs to import. With the above lines added to the path using .., the required file will be imported.
For more on this refer how importing works in python.
When I tried to python running,
I got the error that
ImportError: No module named deepmolecule.rdkit_utils
so I search about "deepmolecule.rdkit_utils" at google, but there are no exist about that module information.
How can I solve this problem?
This is importing modules in the python script file.
import csv
import subprocess
import numpy as np
import numpy.random as npr
import matplotlib.pyplot as plt
import copy
from deepmolecule.rdkit_utils import smile_to_fp
from rdkit.Chem import Descriptors
from rdkit import Chem
from rdkit.Chem import rdMolDescriptors
Apparently, the module got renamed to neuralfingerprint and is called nfp at pypi. Hence, you can install the module by running pip install nfp in your shell. Note that you might need to change the name of the module in your script.
I'm currently learning Python and using spyder 3 as editor.
There are several python packages that I use regularly and, to avoid including them in each new script, I put a list of imports in a script file called autoload.py and hoped that by calling autoload.py the packages in question are automatically loaded. Unfortunately this does not work.
To illustrate, the file autoload.py contains:
import pandas as pd
import os
import matplotlib.pyplot as plt
from functools import reduce
import collections as clct
import numpy as np
import platform
Your help will be appreciated.
Simple, autoload.py contains:
import pandas as pd
import os
import matplotlib.pyplot as plt
from functools import reduce
import collections as clct
import numpy as np
import platform
Your file.py contains:
from autoload import *
file.py load autoload.py content, but surely your IDE throw syntax error before running code. If you try to run, works perfectly. I have tested it in PyCharm and it works.
Anyway, I have to say you that is very bad practice.
Regards.
This worked for me in Spyder 3.1.4(Python 3.6):
autoload.py
import sys
import easygui
test.py
import autoload
print('test')
print(easygui.msgbox('Hello'))
sys.exit()
Like others have mentioned, this is probably not a good approach.
I want to have my python program installed on linux computers (and later windows if someone can help me with that). Ideally this would work on anyone's computer who has python installed, but not all the required modules. I am thinking of this like a C binary/executable after running gcc / make commands.
The hard part is that I don't understand how to handle all the imports required. I keep failing when using py2exe or similiar things because I am using 'GDAL'. So here is what I want to put in my setup.py, but I am so confused. Any help greatly appreciated.
setup.py:
from disutils.core import setup
setup(
name='gui',
version='1.0',
py_modules=['gui'],
install_requires=[],
)
My main files is "gui.py". When I run ipython and then run gui.py my program executes perfectly.
Here are the import statements from the gui.py and the files it includes for reference:
gui.py:
#!/usr/bin/env python
from Tkinter import *
import tkFileDialog
from scipy import *
import spleem_image_class as sic
import spleem_image_display_class as sidc
import matplotlib.pyplot as plt
// code ...
spleem_image_class.py:
# -*- coding: iso-8859-15 -*-
from osgeo import gdal
import scipy
import scipy.interpolate
import itertools
from scipy import ndimage
from scipy.ndimage import morphology
from scipy import math
from scipy import *
import matplotlib.pyplot as plt
from scipy import linalg
// code ...
spleem_image_display_class.py
#!/usr/bin/env python
# -*- coding: iso-8559-15 -*-
import matplotlib.pyplot as plt
import matplotlib.colors
import matplotlib.cm as cm
import colorsys
import scipy.optimize as optimize
from scipy import *
import scipy
import numpy
import sys
import itertools
import spleem_image_class as SI
import pickle
// code ...
It looks like in your setup() you need something like this: packages=['distutils', 'distutils.command'], according to the distutils documentation.